2D Change direction with an arc
Hello,
I'm new to C#/Unity but I'm in PHP for 13 years now... not important :) I have made a 2D airplane which is flying forward (right) on X axis, then when I click with mouse anywhere on screen, I want the plane to go to that target target can be behind airplane or anywhere else..
And I have made that code easily.. but the plane changes direction instantly, and I want it to change direction with smooth & curve.
I have found this code here.. the demo shows the movement I want (change of direction with small arc) http://gamemechanicexplorer.com/#homingmissiles-1
But I was not able to modify it to c# ... :(
Can anyone help me out? Would appreciate it! :) Thanks in advance!
Answer by doublemax · Oct 06, 2016 at 08:28 AM
You probably only need to change one line in your code. This must be somewhere in your Update() method so it gets called on every frame.
float new_angle = Mathf.LerpAngle(currentAngle, destinationAngle, Time.deltaTime );
What it does is just changing the angle over time instead of instantly.
Your answer
Follow this Question
Related Questions
How to cancel the force caused by collision? So the player is not pushed away when it hits a corner? 0 Answers
How do I assign a velocity to an object on only 1 axis? 1 Answer
How to make a 2D object, which can be moved left and right, constantly fall downwards? 1 Answer
How to move a game object to a position after selecting it 0 Answers
Please help with infinite gravity swapping problem 0 Answers