- Home /
Help with this script? Keeps moving my objects around in run-time?
The purpose of this script is when attached to a game object it creates a hovering effect. The only issue is that when play button is hit and the game is running the object that have this script move to different locations. They dont seem to stay in the location I've put them in during edit. What could be causing this?
public class hoveringeffect : MonoBehaviour {
//public float horizontalSpeed;
public float verticalSpeed;
public float amplitude;
public Vector3 tempPosition;
void Start () {
tempPosition = transform.position;
}
// Update is called once per frame
void Update () {
//tempPosition.x += horizontalSpeed;
tempPosition.y = Mathf.Sin(Time.realtimeSinceStartup * verticalSpeed) * amplitude;
transform.position = tempPosition;
}
}
Comment
Your answer
Follow this Question
Related Questions
collider triggers transform position 1 Answer
Trouble converting transform.position to C# 1 Answer
Offset against Rotated Object,Applying Offset to a Rotated Transform 1 Answer
Vector3 sets to different coordinates than specified 1 Answer
How do i make my background keep the same position as my character? 0 Answers