GetPlayerVelocity
#1

Is it possible to shoot a player at such an angle like a cannon with velocity? I try z+1.0 but nothing.
Example please
Reply
#2

You should use SetPlayerVelocity, and an example is included here;

https://sampwiki.blast.hk/wiki/SetPlayerVelocity
Reply
#3

I know Get + Set but what with Z?
Reply
#4

Quote:
Originally Posted by Jefff
Посмотреть сообщение
I know Get + Set but what with Z?
From what i remember SetPlayerVelocity is bugged, it don't work like it should.
Reply
#5

Z on graph is depth, in game is height.
Reply
#6

WHen the player is walking on the ground, the z part will always return 0, even if he walks up a hill or something.
He does not move when you set the z + 1? If yes, try to put him some centimeters into air first with SetPlayerPos, so he is not "attached to ground"
Reply
#7

You use z+0.5? What is z? You only need to use:
pawn Код:
SetPlayerVelocity(playerid,0,0,0.5);
for put the player 0.5 meters higher ..
Reply
#8

I want to launch the player from point X to Y
Reply
#9

Quote:
Originally Posted by Jefff
Посмотреть сообщение
I want to launch the player from point X to Y
I LOL'd at random paint!
Dude read the posts it's explained.
Also learn what the word 'graph' is.
Reply
#10

Quote:
Originally Posted by maramizo
Посмотреть сообщение
I LOL'd at random paint!
Dude read the posts it's explained.
Also learn what the word 'graph' is.
And I LOL'd at your avatar
I got all info i needed from that pic.

If you want to shoot the player EXACTLY at that point, you will have to calculate the values with the gravity. The easiest form would be a parable, a direct line is not possible, you would have to accelerate the player to a giant speed, I dont think thats what you want. Well, if it is, do it that way and ignore all the following stuff

The velocity would have 3 parts:

1. the angle part: use floatsin/floatcos to get the x/y part of the velocity. You will have to set the z angle as you like, (e.g. the direct angle between the points + 10°) Use floatsin(your_parable_angle) and you got the raw z part.

2. the speed part: might be tricky, because the velocity is not m/s afaik. You have to calculate the speed (parable formula, see 3.) and multiply it with all three x/y/z values from 1. But you might also have to find the factor that converts m/s -> samp velocity (shouldnt be hard)

3. The parable formula (requires at least 9. grade maths ) Create a function that calculates the values used in 1/2. from 2 points: the start and the finishing point. Wikipedia or ****** might help you with that. Basically it is just some maths. Use your z angle from 1. as initial angle, add the knowledge of the start and end point (you can simplify this to 2D you just have to find the right speed) and put all this in a parable formula so you can get the initial speed.

(If you love maths and already left school maths behind you can also simplify all this to a 3D parable and just read the x/y/z part out of it. Should be faster then, but you still have to find out the m/s -> velocity factor first)

I did something similar for the autoaiming in my artillery filterscript, but for objects and not players. However, the code is old and it sucks, it is probably harder to read it out of it than to write it yourself. I dont have the time to convert it atm, sorry.


Long text, some work to realize it and some maths. This is the kind of problem I like, finally someone with a good question (All those stupid ones make me tired )
Ill follow this, there ist only ~1 interesting question like this / month
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)