Skip to content

Instantly share code, notes, and snippets.

@minhd
Created December 31, 2017 11:49
Show Gist options
  • Save minhd/48ccfe634723edd3aac57f0ad96f0052 to your computer and use it in GitHub Desktop.
Save minhd/48ccfe634723edd3aac57f0ad96f0052 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bouncing : MonoBehaviour {
public float amplitude = 0.3f;
public float speed = 1f;
private float tempVal;
private Vector3 tempPos;
void Start() {
tempPos = transform.position;
tempVal = transform.position.y;
}
void Update() {
tempPos.y = tempVal + amplitude * Mathf.Sin(speed * Time.time);
transform.position = tempPos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment