I
I
Islam Stanaliev2017-09-25 17:04:03
Unity
Islam Stanaliev, 2017-09-25 17:04:03

How to uniformly move an object (bullet)?

The situation is this - there are 2 players who can move and shoot at each other in the battlefield. When they shoot at each other, the bullet flies in the direction where the opponent was standing at the time of the shot. If the bullet did not hit the enemy, then he simply continues to fly further and hitting the wall, he changes his direction according to the laws of physics and continues on his way. That is, the bullet will never disappear, but will continue to soar in the field.
How to do it? So that the object (bullet) "freely" and evenly flew, and when it collided with the wall, it changed its direction (ricocheted)? (C# script, or how else can you do it).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2017-09-26
@RAINOGD

The easiest way to do this is physics. In order for the bullets to interact with the colliders you need to hang a Rigidbody on them and turn off friction and gravity . In addition, a physical material with zero friction and unity jumping ability must be hung on the bullet collider so that the bullets do not slow down during a collision. When fired, launch bullets with Rigidbody.AddForce or Rigidbody.velocity and after that they will fly forever and bounce off all surfaces.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question