Quantcast
Channel: Answers by "lodendsg"
Viewing all articles
Browse latest Browse all 102

Answer by lodendsg

$
0
0
Assuming your rotating it such that its forward is facing its target then you can simply take its transform.forward as its direction.

e.g.

transform.position += transform.forward;
The above will move the transform forward by 1 unit regardless of the direction its facing.

More info here https://docs.unity3d.com/ScriptReference/Transform-forward.html

As you are working in 2D then you dont want forward you likey want right or up ... these are there as well e.g.

Right = https://docs.unity3d.com/ScriptReference/Transform-right.html
Up = https://docs.unity3d.com/ScriptReference/Transform-up.html

Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>