So I made a script in which when the player walks onto a trigger, it gives a boulder RigidBody2D and therefore making it fall. But it doesn't cause any movement in the boulder, and it doesn't check off a the Boolean I made that will be true when the boulder is falling. BTW, I am very new to unity and C#, but anyway, heres my script:
using
UnityEngine;
using System.Collections;
public class BoulderTrigger : MonoBehaviour {
private Player player;
public bool BoulderFallActive;
public GameObject Boulder;
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").GetComponent();
Boulder = GameObject.FindGameObjectWithTag("boulder");
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag("Player"))
{
if (col.CompareTag("boulder"))
{
Boulder.AddComponent();
BoulderFallActive = true;
}
}
}
}
↧