Created
March 6, 2016 18:45
-
-
Save angelaperrone/a582b99577b6d2f192a5 to your computer and use it in GitHub Desktop.
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.SceneManagement; | |
public class GlassTap : MonoBehaviour { | |
public float speed = 30; | |
//declaring sound variable | |
private AudioSource snd; | |
//declaring rigid body | |
private Rigidbody rb; | |
//not quite sure what this does | |
private Transform trans; | |
// Use this for initialization | |
void Start () { | |
//call rigid body | |
rb = GetComponent<Rigidbody> (); | |
//not quite sure how this grabs speed and uses it | |
rb.velocity = Vector3.right * speed; | |
//get sound | |
snd = GetComponent <AudioSource> (); | |
//I believe this calls the action on this particular object | |
trans = this.transform; | |
} | |
//ask the sound to play on collision with the HandController | |
void OnCollisionEnter3D(Collision col){ | |
if (col.gameObject.name == "HandController") { | |
float y = calculatePosition (transform.position, col.transform.position, col.collider.bounds.size.y); | |
Vector3 direction = new Vector3 (1, y).normalized; | |
rb.velocity = direction * speed; | |
snd.Play (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment