Hello,
I’m trying to get familiar with the Unity Game Engine and I’m doing a small Pong type game to show to my colleagues. The one thing I am having difficulty with is the Paddle (player controlled) check to see it is colliding with the bounds. The cube objects (called “bounds”) are tagged as “bounds.” I’m trying to CompareTags during the collision event
NOTE: There are no rigidbodies on any of these objects
private var paddlePos: Vector3;
static var pLives: int;
var prefabBall: Transform;
var moveSpeed: float = 1.0;
function Start()
{
paddlePos = this.gameObject.transform.position;
}
function OnTriggerEnter(other: Collider)
{
if(other.CompareTag("bounds"))
{
Debug.Log("Collided");
}
}
function Update ()
{
if(Input.GetButton("Up"))
{
transform.position += transform.right * moveSpeed * Time.deltaTime;
}
if(Input.GetButton("Down"))
{
transform.position -= transform.right * moveSpeed * Time.deltaTime;
}
}