02.12.2015, 10:57
I'm currently working on knife throwing system and have a problem with it.
MoveObject(KnifeObject[playerid], targetpos[0], targetpos[1], targetpos[2], 12.0);
With this code, knife will move right into player and it gets destroy after 1 second. That means in this case it hits target(player).
Problem is...
When knife doesn't "hit" player, I want it flew past him. I don't know how to make knife go further than player position. I know that I have to add some value to x and y cords, but I don't know how to determine how much to add, since knife can be thrown at any direction.
Getting player angle is not a solution because player can throw knife to target while not facing that target.
Here's some pictures to make it more clear(im a paint master) :
Knife hits player (everything ok) :
Knife doesn't hit player and move past him, further (don't know how to do that) :
MoveObject(KnifeObject[playerid], targetpos[0], targetpos[1], targetpos[2], 12.0);
With this code, knife will move right into player and it gets destroy after 1 second. That means in this case it hits target(player).
Problem is...
When knife doesn't "hit" player, I want it flew past him. I don't know how to make knife go further than player position. I know that I have to add some value to x and y cords, but I don't know how to determine how much to add, since knife can be thrown at any direction.
Getting player angle is not a solution because player can throw knife to target while not facing that target.
Here's some pictures to make it more clear(im a paint master) :
Knife hits player (everything ok) :
Knife doesn't hit player and move past him, further (don't know how to do that) :