Quantcast
Channel: Latest Questions by Selzier
Viewing all articles
Browse latest Browse all 34

Get a var's value plus X without modifying?

$
0
0
My camera follows (looks at) a GameObject that needs to be at the Player's 0,0,0. However I want the camera to follow 5 units in front of this GameObject. No matter what I've tried, the camera always moved forward 5 units, saves it's location, so when I run the game, the camera flies away. void Update(){ target.position.x += 5f; } I basically want to call the line above, WITHOUT saving that value to the actual position. void Update(){ Transform temp = target; temp.position = new Vector3( temp.position.x + 5f, temp.position.y, temp.position.z ); } But this does not work either. Any Ideas how I can simply add X to a Transform.Position without moving it, or somehow put that into a temporary Transform that is reset each frame? The point is I need to calculate an offset while keeping the "LookAt" GameObject at player's 0,0,0. Thanks!

Viewing all articles
Browse latest Browse all 34

Trending Articles



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