Can anyone help me, by explaining how can i change the speed of an object that is instantiated and already moving?
The variable “ballSpeed” is used at the initial movement and change it does not affect the speed of the instantiated ball.
How can i find what is making the instantiated object move and change its value?
I tryed to use this “InvokeRepeating” but the “rb.AddForce(ballSpeed*1.5f, ballSpeed * 1.5f, 0,ForceMode.Force);” makes the ball act strange and changing its direction.
I read a lot of posts in the forum and tryed some solutions but i couldnt make it work.
AddForce should be called in FixedUpdate, not Update, but Input.GetButtonDown shall be called in Update. So you need somehow to setup a state machine to code it properly.
Look at this video based on Tanks! tutorial setting up a state machine with the shell firing: