Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Intro_Scritping/Week5 Class Proj/Assets/Scripts/Ball.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (20 sloc)
543 Bytes
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; | |
public class Ball : MonoBehaviour { | |
public float ballIntVelocity = 600f; | |
private Rigidbody rb; | |
private bool ballInPlay; | |
// Use this for initialization | |
void Awake () { | |
rb = GetComponent<Rigidbody> (); | |
} | |
// Update is called once per frame | |
void FixedUpdate () { | |
if (Input.GetButtonDown ("Fire1") && ballInPlay == false) { | |
transform.parent = null; | |
ballInPlay = true; | |
rb.isKinematic = false; | |
rb.AddForce(new Vector3(ballIntVelocity, ballIntVelocity, 0)); | |
} | |
} | |
} |