vehicle flight (math and such)
#1

Alright so what im trying to achieve is quite simple, when you shoot a car, its position will be change, in a way like you have kicked a ball with your leg and it will fly for lets say 20 meters.

Now my problem is huge. I suck at math. I tried doing some stuff, ended up horrible to be honest, even crashed my entire server with it once.

Now what would be the proper calculation for it?

For example I know Id have to rotate the vehicle at certain angle, like 1m every 100 ms and such (maybe 200ms) but what about the rest?

I want of it to naturaly turn this way:

A: If I shoot the car from the front, it will go backwards
B: If I shoot the car from the back it will go forward

Same like you hit a ball with ya leg.

So yeah, any suggestions? Or even some math calculations for this?

And once again, I want to achieve this with vehicles. Imagine something like /throwcar where u would launch a car to fly certain distance naturaly.
Reply
#2

I don't see how you're going to do this, other than making the vehicle move with object(s). If that would even work.

Setting the vehicle's position wouldn't come out that nice.
Reply
#3

Unless I'm not understanding correctly, you should use SetVehicleVelocity.
Also, look at how ******'s GetXYInFrontOfPlayer works, and do the same thing.
That should help you get the correct angle.
Reply
#4

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Unless I'm not understanding correctly, you should use SetVehicleVelocity.
Also, look at how ******'s GetXYInFrontOfPlayer works, and do the same thing.
That should help you get the correct angle.
This function has no affect on un-occupied vehicles and does not affect trains.

https://sampwiki.blast.hk/wiki/SetVehicleVelocity
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
This function has no affect on un-occupied vehicles and does not affect trains.

https://sampwiki.blast.hk/wiki/SetVehicleVelocity
Yes, you're correct but he never said anything about the state of the vehicle
(Sorry if I'm missing something in the post, I haven't slept all day)
It could still help him if he wants to use it on occupied vehicles.
Reply
#6

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Yes, you're correct but he never said anything about the state of the vehicle
(Sorry if I'm missing something in the post, I haven't slept all day)
It could still help him if he wants to use it on occupied vehicles.
Quote:
Originally Posted by TwinkiDaBoss
And once again, I want to achieve this with vehicles. Imagine something like /throwcar where u would launch a car to fly certain distance naturaly.
Throwing a car away while you're inside it doesn't seem like something someone would want (speed boot can do that, it's controllable as well).
Reply
#7

Well yeah sorry about that i wanted to say un occupied vehicles
I was basically also thinking of making a car at exactly same position of the current one and then despawn it, that can glitch out the car and it gets naturally pushed but preety much cant control much of it. Its that good old GTA SA glitch
On the otherhand i was also thinking of adding a npc into the car temporarly and then make a set of explosions to push it, altho im highly un experienced with npcs so ill have to find some good ways with it.
Now, could it be possible to spawn NPC in a car nearby and make it drive insanely fast towards that direction and push the target car? Switching Virtual world of the npc like .200m beffore the impact and on impact (destnation reached) despawn it.
My question is, how could i make that path towards the car dynamic so it can allow npc to do that..
Reply
#8

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Well yeah sorry about that i wanted to say un occupied vehicles
I was basically also thinking of making a car at exactly same position of the current one and then despawn it, that can glitch out the car and it gets naturally pushed but preety much cant control much of it. Its that good old GTA SA glitch
On the otherhand i was also thinking of adding a npc into the car temporarly and then make a set of explosions to push it, altho im highly un experienced with npcs so ill have to find some good ways with it.
Now, could it be possible to spawn NPC in a car nearby and make it drive insanely fast towards that direction and push the target car? Switching Virtual world of the npc like .200m beffore the impact and on impact (destnation reached) despawn it.
My question is, how could i make that path towards the car dynamic so it can allow npc to do that..
That doesn't seem quite viable and a bit abusive. So imagine a player keeps shooting a vehicle and another players wants to enter the vehicle, the NPC would just keep reappearing in the vehicle preventing the player wanting to enter the vehicle, well, from entering. You would also need an NPC connected for each player slot you have, if you want this to always work for everyone of course.

My idea is to somehow push the vehicle with an invisible object, that's the only viable method I can think of.
Reply
#9

True true. Ill have to think of sonething for this kicking, i just hope ill find another way besides SetVehiclePos and such because It looks awfull with it. Thanks for all ideas lads! Highly appreciated!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)