Created
October 9, 2015 06:29
-
-
Save neuman/1c2315c9bb7d9b936682 to your computer and use it in GitHub Desktop.
Unity Hovering Animation Behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
public class HoverBob : MonoBehaviour { | |
float originalY; | |
public float floatSpeed = 1; | |
public float floatStrength = 1; | |
void Start() | |
{ | |
this.originalY = this.transform.position.y; | |
} | |
void Update() | |
{ | |
transform.position = new Vector3(transform.position.x, | |
originalY + ((float)Math.Sin(Time.time*floatSpeed) * floatStrength), | |
transform.position.z); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment