|
Post by A Random indie dev on Dec 1, 2016 7:00:08 GMT
Hi, i need the player to lock on the nearest enemy automatically. can someone guild me to what part of the code i should modify?
|
|
|
Post by hamzah on Dec 1, 2016 11:41:15 GMT
Hi, i need the player to lock on the nearest enemy automatically. can someone guild me to what part of the code i should modify? hey bro, i think this might work. in the script vLockOnTargetControl try increasing the value of range and inside v3rdPersonCamera make a method, name it "autoLock" and call it inside Init() method of same v3rdPersonCamera. I hope this will do the trick ;) void Init(){ -- --
//invoking autoLock method on initialization and repeating it in every 0.25 seconds for optimization
InvokeRepeating("autoLock",0,0.25f); }
void autoLock(){ UpdateLockOn(true); }
|
|
|
Post by A Random indie dev on Dec 1, 2016 16:38:49 GMT
Thanks hamzah
|
|
|
Post by A Random indie dev on Dec 1, 2016 18:15:06 GMT
i tried the solution above and it still will not work. if player and 1 enemy are standing right next to each other, i just need the player to lock on to the enemy at start without and input being used.
|
|
|
Post by hamzah on Dec 2, 2016 4:51:08 GMT
i tried the solution above and it still will not work. if player and 1 enemy are standing right next to each other, i just need the player to lock on to the enemy at start without and input being used. hmm, i see. try this - Go inside vLockOnTarget script - Find target variable - Make it public if it's not already. - Now you have to manually set it's transform to the Enemy. - Now call this from Start() method of vLockOnTargetControl but make sure your target is set to your enemy before doing it.void Start() { Init(); SendMessage("UpdateLockOn",true); }
|
|
|
Post by hamzah on Dec 2, 2016 16:39:33 GMT
hey guys, is someone having this weird issue. if the enemyAI is bare handed, he is playing all 2-3 ATK animations, but if he's equipped with a wpn, he plays only first ATK animation. I have checked the iterations time, animator controller, have talked to invector via email. bt the issue remains.. plz help. :/ attaching a snippet of inspector. this might help photo hosting
|
|
|
Post by dreadlord on Dec 2, 2016 16:46:12 GMT
give them more attack time
|
|
|
Post by Chronicman on Dec 2, 2016 17:37:19 GMT
The AI has the stamina to preform all 3 actions ?
|
|
|
Post by hamzah on Dec 3, 2016 4:54:04 GMT
give them more attack time still playing first animation
|
|
|
Post by hamzah on Dec 3, 2016 4:55:07 GMT
The AI has the stamina to preform all 3 actions ? the AI is having stamina of 5000, nd each action costs stamina of 25. Still playing first animation
|
|
|
Post by hamzah on Dec 3, 2016 15:19:40 GMT
hey guys, ummm, that problem(AI playing only first ATK animation) didn't solved so i had a work around. can you all tell me does this solution seems digestible to u guys I have changed the code of MeleeAttack() of v_AIAnimator, which will be playing either a Strong ATK or a Weak ATK based on the randomATK count. int randmATK;
public void MeleeAttack()
{
if (animator != null && animator.enabled && !actions)
{
isBlocking = false;
randmATK = UnityEngine.Random.Range (1, 100);
Debug.Log ("randmATK " + randmATK);
if(randmATK % 2 == 0)
animator.SetTrigger("WeakAttack");
else
animator.SetTrigger("StrongAttack");
}
} P.S : The gameplay looks more fine and random now
|
|
|
Post by Chronicman on Dec 3, 2016 20:56:13 GMT
Nice work around, I was thinking of doing something similar with my Rpg addon.
|
|
|
Post by hamzah on Dec 4, 2016 1:32:05 GMT
Nice work around, I was thinking of doing something similar with my Rpg addon. Thanks man, i wish i can also support invector community like you.
|
|
|
Post by Chronicman on Dec 4, 2016 1:49:36 GMT
It just takes time mate, I started knowing nothing. I code for like 17 hours a day for the last year or so.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 4, 2016 2:23:42 GMT
Nice, yeah, I'm still learning lol
|
|