Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

SmoothDamp not working perfectly?

$
0
0
So I'm trying to make a sort of drawer that contains items the player can use. The items (which are prefabs) will all be children of an empty object that will move them all together. The code I have sort of works? In that the objects move, but only by a couple of hundreths of a unit, and not in one big movement, instead you have to click the activator object a couple of dozen times to actually see them move at all. Maybe I'm just doing something really stupid? I've been playing around with this for a few days now and have gotten the example of SmoothDamp in the unity docs to work, but trying my own twist on it doesn't produce the results I want. So here's my code : var atomSpawner : Transform; var drawerOpen : boolean; var startPos : Vector3; var endPos : Vector3; var smoothTime = 1; private var moveSpeed = Vector3.zero; function Update () { if(selectedOn == false){ if(hit.collider.tag == "slider"){ atomSpawner.transform.position = Vector3.SmoothDamp(atomSpawner.transform.position, startPos, moveSpeed, smoothTime); drawerOpen = false; } } else{ if(hit.collider.tag == "slider"){ atomSpawner.transform.position = Vector3.SmoothDamp(atomSpawner.transform.position, endPos, moveSpeed, smoothTime); drawerOpen = true; } } Any and all help is appreciated!

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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