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