October 2017
Intermediate to advanced
548 pages
13h 23m
English
We will now write a CollisionBehavior script to handle the collision events on the goal. In the Project Assets/ARBallPlay/Scripts/ folder, create a C# script named CollisionBehavior. Add the component to the GoalCollider object and then open it for editing. The full script is as follows:
File: CollisionBehavior.csusing UnityEngine; using UnityEngine.Events; public class GameObjectEvent : UnityEvent<GameObject> { } public class CollisionBehavior : MonoBehaviour { public GameObjectEvent OnHitGameObject = new GameObjectEvent(); public UnityEvent OnCollision = new UnityEvent(); // used to make sure that only one event is called private GameObject lastCollision; void Awake() { //disables the renderer in playmode if ...Read now
Unlock full access