Moving object past player (with pictures)
#1

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) :
Reply
#2

I am not the best at maths tbh but i think it can be done by adding a 5 to either the x or the y and another 5 to the z.
And then use the correct rotations to make it face up.

To determine which one to add to, you need to get the rotation where the arrow is being shoot and calculate from it.

Don't ask me how though.. I don't know but just trying xd
Reply
#3

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
I am not the best at maths tbh but i think it can be done by adding a 5 to either the x or the y and another 5 to the z.
And then use the correct rotations to make it face up.

To determine which one to add to, you need to get the rotation where the arrow is being shoot and calculate from it.

Don't ask me how though.. I don't know but just trying xd
Well, that didn't help at all, because you just repeated what I said about this. Thanks for trying
Reply
#4

Ok, I decided that this is impossible(or very hard to calcute and I'm lazy) to find arrow rotation. So I'll try to do this with player rotation.
And I'm not sure how to do even that...

Код:
new Float:Angle;

GetPlayerFacingAngle(targetid, Angle);
if(Angle==180) y++;
Right? But how to know how much X and Y to add when rotation angle is for example 32?
Reply
#5

It's not even remotely hard to understand how to make it, unless you didn't really pass geometry ( or well trigonometry )
Here is a suggestion, you know where you are throwing it from (player pos ?) and you know where you are throwing it to (target pos), You have all the ratios, it's simply a matter of adding 5.0 meters or something to vectorsize, turn it back to coordinates and then applying it with moveobject
Reply
#6

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
It's not even remotely hard to understand how to make it, unless you didn't really pass geometry ( or well trigonometry )
Here is a suggestion, you know where you are throwing it from (player pos ?) and you know where you are throwing it to (target pos), You have all the ratios, it's simply a matter of adding 5.0 meters or something to vectorsize, turn it back to coordinates and then applying it with moveobject
So how do I add 5.0 meters or something to vectorsize (by code, with MoveObject function)?
Reply
#7

Show code as it currently operates
Reply
#8

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
Show code as it currently operates
Umm, I already did, but ok

Код:
MoveObject(KnifeObject[playerid], targetpos[0], targetpos[1], targetpos[2], 12.0);
Reply
#9

I'll try to write a script
Reply
#10

can you give me this script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)