How do i use ForceMode.impulce with transform

I’m making a turret in my game and I want to make bullets that bounce of the walls so I want to use transform instead of rigidbody.addforce so I can shoot a bullet towards the player, but for this, I need to use ForceMode.Impulse, the only issue is that i can’t find a way to use ForceMode.Impulse in my transform.translate moving script for the bullet

I am bad at explaining things and I’ve only been coding for 2 months, watching youtube tortures from different youtubers

basicly i need help to add transform to my movement script on line 11

{
    Rigidbody rb;
    public float moveSpeed = 10f;    //this is a failed part of code that i tried to make other code witch failed
    public Vector3 startForce;


    void Start()
    {
         rb = GetComponent<Rigidbody>();    //gets the bullets rigidbody so i can add momentum
       transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);     // this code dosent allow my ball to bounce
       rb.AddForce(startForce, ForceMode.Impulse); //this code almost works but is locked to the worlds cords           adn this is the code im trying to add transfrom to so it wont be locked on the world cord
    }

and yes i added the physics material i think its called and tested o make sure it was bouncy its a error in my code

Short answer is, you absolutely don’t. The whole point of adding a Rigidbody is so that it can simulate physics and then write its pose to the Transform i.e. it’s a proxy to the Transform. This means you need to stay away from writing to the Transform.

Use the Rigidbody API to cause changes to the Transform. Add forces, set velocities. move position/rotation etc.

Rule#1: Don’t modify the Transform when using physics, let the Rigidbody do thay.

1 Like