Collision With Text
Hi everyone.
I am trying to make a game for my school for the languages department where you shoot the correct answer to the question.
The problem I have been having is that I need the answers to be different every time, so I have tried using both UI text and 3D text to be able to change the words. I have put a box collider on the word but it does not detect when it is hit with the projectile (also with a box collider).
I have put a sample of the code I have tried to use. (It also includes a score system).
public Text scoreText;
private int score;
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.name == "projectile(Clone)")
{
score++;
scoreText.text = "Score: " + score.ToString();
}
}
Many Thanks in Advance, Craig
is there a RigidBody2D component attached to both gameobjects?
WHen i did my collider part for my Game i set one of the Collider to trigger, i advise you to check Triggers
Your answer
Follow this Question
Related Questions
Collision is not working with some Collider2d 1 Answer
Collision or Triggers both not working. 3D. 1 Answer
2D Collisions Not Working,2d Collision not working? 0 Answers
Unity Collider2D is causing the game object to disappear upon collision? 1 Answer
How to make an object that collides with just the player? 1 Answer