Question by
GVELOPER · Feb 20, 2020 at 02:56 PM ·
collisioncollidercollision detectionpause game
cant pause game when character collides,cant pause when my character dies
i have this code to pause my game when my character collides but nothing happens
using UnityEngine;
using System.Collections;
public class Collision : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "rocket")
Destroy(gameObject);
Time.timeScale = 0f;
}
}
Comment
Best Answer
Answer by tormentoarmagedoom · Feb 20, 2020 at 04:45 PM
Hello.
You have syntax error..
you forget the Bracets for the if statement...
if (coll.gameObject.tag == "rocket")
{
Destroy(gameObject);
Time.timeScale = 0f;
}
Your answer
Follow this Question
Related Questions
Ignore collision based on position 1 Answer
How to make an object that collides with just the player? 1 Answer
ontriggerexit not working 0 Answers
Collision between objects not being detected 0 Answers
Determine collision points/area 0 Answers