Files
blackhole-escape/Assets/Scripts/Scripts/AsteroidBoundaryCheck.cs
iDunnoDev 0360907df1 Added Main menu Changes to UI
Added Rules Menu Changes to UI
Added Cutscenes to the rules scene
Reorganised Files
2022-06-22 13:30:58 +01:00

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);
}
}