- Home /
Pong reset state not working correctly
This script is causing my goal to reset at (0,0) instead of my ball and i'm not sure why
using UnityEngine; using UnityEngine.SceneManagement; using System.Collections;
public class BallCollision: MonoBehaviour {
void OnTriggerEnter2D (Collider2D Ball)
{
if(Ball.gameObject.tag == "Goal")
{
Ball.transform.position = new Vector2 (0, 0);
}
}
}
Just because you call the object "Ball" doesn't mean that its actually the ball, you are checking to see if the object tag is "Goal", then setting the position of that object (which you just verified is the goal object) to zero. Is this script on your ball? Then you could just call transform.position = new Vector2(0, 0);
If you don't $$anonymous$$d could you go into more detail on the changes I should make?
and this is a separate script call Ball Collision
nvm getting rid of the "Ball" in Ball.transform.position = new Vector2 (0, 0); did the trick
Thanks for the help!
Your answer
Follow this Question
Related Questions
3drd person camera reset 0 Answers
Score Help!!!! 2 Answers
Can't reset speed 1 Answer
cant set button back to original size and position after running 2d animation 0 Answers