Quantcast
Viewing all articles
Browse latest Browse all 104

Up and Down Cubes Shaking Issue.

Ok so i use the code below for my cubes to go up and down in the Y axis. I just want that simple thing. Up and Down so that my player (First Person Controller) can go up and jump to the next. The only problem is that when the player is on the cube, the cube or should i say all the cubes start shaking. Is there a way to fix this? Is there a simpler code? var maxUpAndDown : float = 1; // amount of meters going up and down var speed : float = 50; // up and down speed protected var angle : float = -90; // angle to determin the height by using the sinus protected var toDegrees : float = Mathf.PI/180; // radians to degrees protected var startHeight : float; // height of the object when the script starts function Start(){ startHeight = transform.localPosition.y; } function Update(){ angle += speed * Time.deltaTime; if (angle > 270) angle -= 360; transform.localPosition.y = startHeight + maxUpAndDown * (1 + Mathf.Sin(angle * toDegrees)) / 2; }

Viewing all articles
Browse latest Browse all 104

Trending Articles



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