- Home /
OnTriggerEnter Collision
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;
}
}
Answer by StephanK · Aug 03, 2011 at 07:47 PM
If there are no rigidbodies on your objects there will be no collision detection. For a collision (or a trigger event) at least one of the intersecting objects needs a rigidbody.
So I would have to check off "Use Gravity" and check on "Is $$anonymous$$inematic" would that help?
If you don't want the object to be moved by physics but need the rigidbody for trigger events you turn on is$$anonymous$$inematic.
Okay I figured it out I had to make the bounds objects isTrigger and is$$anonymous$$inematic both on. Thanks guys! I knwo it was a really simple question, but I appreciate the help :^)
Your answer
Follow this Question
Related Questions
How come the Trigger teleports when its not supposed to! 1 Answer
Trigger not detecting tag 1 Answer
Ignore collision on tag not working 2 Answers
Desperate need for help with Trigger/Collider functions. 1 Answer
Tag Player in VRTK 1 Answer