October 2017
Intermediate to advanced
548 pages
13h 23m
English
To begin, in your Project Assets/ARPlayBall/Scripts folder create, a new C# script named ThrowControl and open it for editing. First, we'll write the following code that resets the ball to its ready state:
File: ThrowControl.csusing UnityEngine; using UnityEngine.Events; public class ThrowControl : MonoBehaviour { public float ballStartZ = 0.5f; public UnityEvent OnReset; private Vector3 newBallPosition; private Rigidbody _rigidbody; private bool isHolding; private bool isThrown; private bool isInitialized = false; void Start() { _rigidbody = GetComponent<Rigidbody>(); ReadyBall(); isInitialized = true; } void Update() { } void ReadyBall() { CancelInvoke(); Vector3 screenPosition = new Vector3(0.5f, 0.1f, ballStartZ); transform.position ...Read now
Unlock full access