Hi
I am making my first game with unity and I have a script to crush the player. In this script I also have a collision detecting function.
here is my script:`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class CrushingThePlayer : MonoBehaviour
{
public bool isCollidedWithWall = false;
public bool isCollidedWithCube = false;
public void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Wall")
isCollidedWithWall = true;
else if (collision.gameObject.name == "MovaeableCube")
isCollidedWithCube = true;
if (isCollidedWithWall && isCollidedWithCube)
SceneManager.LoadScene("Scene1");
}
public void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Wall")
isCollidedWithWall = false;
else if (collision.gameObject.name == "MoveableCube")
isCollidedWithCube = false;
}
}
I want the same script, but with a child that detects the collision.
I now have if (collision.gameObject.name == “MoveableCube”) but want to do it with a child of the cube
if someone knows how to do this please tell me.