I am facing a problem below is the detail.
- There are two scripts(actually more than two but these have the problem) Cannon.cs and Launch.cs and three buttons(up, down, and launch) to move cannon and launch the bullet.
- Cannon have bullets and each bullet has Launch.cs attached also a RigidBody2D.
- When specific event occurs the Cannon.cs calls the Launch.cs's
- Parameter "direction" = Cannon.transform.right.
- Bullets are being instantiated dynamically and are stored in the list Cannon.cs take one bullet and fires it(firing includes calling the
Launch(direction); will always be called once no matter what also to double sure myself I destroy the launch script on launch.
The problem is once the bullet is fired or launched in the direction specified by the direction of cannon(since
direction = cannon.right) and I click on the up or down button the launched bullet changes its direction which should never happen because Launch() method is called only once in the lifetime of the bullet and also I detach the Launch.cs script on launch.
I am using
rigidbody2D.velocity = direction * thrust; what I think is that rigidbody2D.velocity once called will possess the direction just like a method called by reference. I am totally lost I hope I made my question clear please do help me if you can.