- Home /
It's my question and i'd like to close it
I have a game...
Please help! :| when I am going to support soldier and colliding to him, THE GUITEXT text IS NOT CHANGING!!! I am sure my code is right! ok thankx for any help :) HEre is script: var targetGuiText : GUIText;
function Start()
{
targetGuiText.text = "Objective: find a support soldier";
}
function OnCollisionEnter(collision : Collision)
{
if (collision.gameObject.name == "supportSoldier")
{
targetGuiText.text = "Objective complete!";
}
}
If anyone didn't notice there is more code. It's just above the code block.
Just a quick question, you are attaching the script to the player right?
If your soldier is using a character controller you might have to use OnControllerColliderHit() rather than OnCollisionEnter()
Answer by tanoshimi · Dec 01, 2013 at 08:16 AM
Is there a rigidbody on at least one of the game objects?
Is there a collider on both of them?
Is the object you're colliding with definitely called "supportSoldier"?
Is the collision being detected at all? If so, what with? i.e. what does this do:
function OnCollisionEnter(collision : Collision)
{
Debug.Log("Collided detected with: " + collision.gameObject.name);
if (collision.gameObject.name == "supportSoldier")
{
targetGuiText.text = "Objective complete!";
}
}
Follow this Question
Related Questions
spheres not colliding with world 1 Answer
GetComponent() problems 2 Answers
how to change the path of the sdk? 1 Answer
Rotating gameobject not colliding 0 Answers
Rig and animate a model in unity 3d? 1 Answer