- Home /
2D bullet trajectory prediction (line renderer)
Hello, I’m trying to make a trajectory for predicting the flight of a projectile of my grenade launcher. However, the trajectory is drawn incorrectly. When the grenade launcher fires, the bullet flies in the direction of the barrel of the grenade launcher. The grenade launcher turns in the direction where the joystick is moved.
The script for the direction of the bullet depending on the rotation of the joystick: curBulletGL.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward); where angle - angle = Mathf.Atan2(shootDir.y, shootDir.x mult) Mathf.Rad2Deg; where shootdir.x and shootdir.y is my joystick - shootDir = joystickShoot.Direction;
Bullet Flight Script: rb.AddRelativeForce(new Vector2(bulforceGL, 0)); rb - public Rigidbody2D rb;
I call the trajectory through the method of this script: The line for calling the trajectory: where curbulletPosGl is the empty object on the stage, which is located near the barrel of the grenade launcher, and BulletFlyScriptGL.bulforceGL is the speed of the bullet.
As I understand it, the trajectory that is being calculated at the current moment does not take into account the bullet’s rotation in the direction where the joystick is turned, and also does not take into account the mass. I also attach a video demonstration: https://youtu.be/D2dR3kEM05E Thank you in advance for your help
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Tweaking the Trajectory Simulation from the wiki 0 Answers
2D bullet spray problems 1 Answer