Hi,
Currently in my project I am using translation based movement to control my floating character which can move in all dimensions.
My character fires a projectile which is physics based and uses force to move it. When I shoot I find that my projectile does not take into account my relative speed, and it just looks / feels wrong. For example if I am moving left and fire, the projectile very quickly falls away to the right. I am guessing this is because it has no reference to any other physics velocity.
Am I going about my project structure the wrong way? If I am using any physics for one item should I be using physics for everything. Or is it OK to blend the two?
Thanks
Paul
No, no, yes (but not on same object.)
No matter what, if you want to fire a bullet taking into account your velocity, you’ll have to do it yourself. When you Instantiate a “physics object” (a rigid body) it has speed=0. Way too confusing for Unity to check whether the spawning script is on an RB and tweak speed if so.
If you want to give it your speed, add it: bullet.rigidbody.velocity = transform.forward*20 + AAA;
. If you’re a physics object, AAA is rigidbody.velocity
(your speed.) If you have the standard third-person script, AAA is moveDirection
(physics velocity is M/S, so make sure you don’t use your per/frame speed by mistake.)
The thing that usually causes problems is when the same object uses code movement and physics-system movement. So if you want your bullet to jerk sideways mid-flight, set rigidbody.velocity
to sideways (or temporarily turn off physics for it with isKinematic
and begin using translate.)