Quantcast
Channel: Latest Questions by secondry2
Viewing all articles
Browse latest Browse all 28

Failing to detect X,Y,Z Locations of GameObject

$
0
0
Hi guys! Ive got this code, thats suppose to move a lantern toward the player and down to imitate a running effect, once it reaches a certain point, its suppose to stop which it is failing to do. (I will also add functionality for it to bob once i get this simple mechanic down pat) Thanks! Script: var posZ = -0.5948148; var posY = -0.6899948; private var moveSpeed = 0.1; private var orgSpeed = 0.1; var lantern : Transform; function Update () { if ( Input.GetKey(KeyCode.LeftShift) ) { if (lantern.position.z >= posZ && lantern.position.y <= posY) { moveSpeed = 0; Debug.Log("STOPPED"); } else { lantern.position.z += moveSpeed * Time.deltaTime; lantern.position.y -= moveSpeed * Time.deltaTime; } } }

Viewing all articles
Browse latest Browse all 28

Trending Articles



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