|
I want to knock back an enemy when they are hit by the player. The enemy has a custom script that handles gravity (It has a character controller). Here is the script:
Now, I have a script that handles the damage calculation when they are hit. I want to handle the knockback here. Here is the function from that script:
This line is suppose to move the enemy in the opposite direction (even though right now, its more like warping and I'm not sure how to fix that, maybe time.delta?) but it only works for one direction.
Can anyone help me with this?
(comments are locked)
|
|
I would place this function on the enemy, and call SlamBack when he has to get slammed.
To get him slammed longer, you make slamDistance greater, and to make him come to a rest slower, you edit smoothTime. Is this the kind of interpolation you are looking for? I'm such a novice, do I called this inside the ApplyDamage function? and if so, what what do i put in the param?
Nov 02 '10 at 03:41 AM
SirVictory
like SlamBack(param);?
Nov 02 '10 at 03:42 AM
SirVictory
Oh i think i got it! SlamBack(transform.TransformDirection(slamDirection)); it that the best way for me to do it?
Nov 02 '10 at 03:47 AM
SirVictory
I'm not sure what that would do.. :) I would use SlamBack(slamDirection * strength)
Nov 02 '10 at 03:50 AM
Atnas1010
SlamBack(slamDirection * -strength); worked for me, the other way around did the opposite.
Nov 02 '10 at 04:03 AM
SirVictory
(comments are locked)
|
|
I am sure of one thing:
I hope this has helped you =) EDIT: You can try this for the animation: Thanks, this works as far as sending the enemy in the right directions, but how would I interpolate the motion? Right now the enemy just kind of warps ahead.
Nov 02 '10 at 03:05 AM
SirVictory
I meade a small edit on my Answer, I think that this will make your animation look right.
Nov 02 '10 at 03:39 AM
IJM
Thanks for the initial answers. I wish I could check yours up also!
Nov 02 '10 at 04:04 AM
SirVictory
Npa mate ;) I'm glad that I helped. Now when I see the answer, I realize that I didn't understand the question correctly =)
Nov 02 '10 at 04:55 AM
IJM
(comments are locked)
|
