Hello, I can’t for the life of me seem to get this to work, my projectiles use Rigidbodys
Basically I just need a projectile physics script that works from a moving target.
Imagine you’re riding a motorcycle north, and then fire a flare gun to the west .
That flare should go west, but still maintain some of the northern momentum.
I need that principle to work in my game.
I’ve tried everything I could find Google.
If anyone out there can show me a working example of a Rigidbody projectile that inherits it’s shooters momentum upon firing, It would be greatly appreciated.
I need a hero lol, this last unity physics challenge is defeating me and my game, and I only have an hour or two a day to create between my work and kids.
Add the velocity of the “motorcycle” Rigidbody to the “projectile” Rigidbody.
For some reason that isn’t working for me correctly.
How are you adding the the velocity exactly
Via add force, or just a simple +?
You only said “that isn’t working” which could mean anything. Maybe provide some more info and scripts on how it’s not working and what you’re doing.
If you don’t follow what I just suggested then honestly I’m not sure how else to tell you as it’s pretty basic. Certainly AddForce has nothing to do with getting the velocity of the motorcycle using the velocity property and adding it to the projectile velocity you choose.
projectile.velocity = baseProjectileVelocity + motorcycle.velocity
That’s exactly what I’ve done, it just doesn’t behave like any kind of real physics I’ve ever seen. The bullet looks like it’s coming from way off to the side. I can see a noticeable difference in the way the bullet behaves from before, it’s definitely inheriting the players velocity, but it’s still unusable.
To be fair, I followed exactly what you mentioned, but I didn’t know how to explain the funky physics I’m experiencing. I can’t post a script at the moment because a tornado knocked out my neighborhoods internet, so I’m phone bound as far as forums go, I guess my question will have to wait till I can post a script again. I was just hoping for an example I could read line by line and figure it out from there.
I just figured out what I’m going to do, it completely out there but it looks the way I want it. I’ll post my script once the internet guys hook my box back up. But if anyone is looking for more of an action movie style physics for shooters, it might help.
thanks for your help
1 Like
Good luck, hope you get connected again soon!