using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// Class for keeping the asteroids inside of the boundary /// public class AsteroidBoundaryCheck : BoundaryCheck { private Rigidbody _coreObjectRigidBody; // Start is called before the first frame update void Awake() { _coreObjectRigidBody = gameObject.GetComponent(); } /// /// Method for bouncing this object back when hitting the boundary /// /// The point of the boundary hit. /// How much force to apply to this object public override void DoBoundaryPushback(Vector3 contactPoint, float pushbackForce) { _coreObjectRigidBody.velocity = Vector3.zero; _coreObjectRigidBody.AddForceAtPosition(contactPoint * pushbackForce, contactPoint, ForceMode.Impulse); } }