So, I am pretty new to Unity, and I’ve been working with one of the tutorial projects trying to add things and troubleshoot coding with the search feature, but I’m getting stuck on a problem.
I’m trying to set up a box collider trigger so that when my character (A Marble) falls off of the stage it will reappear back in bounds.
The default spawn position is 0,0,0 so I wanted the marble to appear above that to avoid clipping. My main problem is that I cant figure out exactly how to word the scripting so that its syntax is functionable.
Im trying to add this script to a box that I set up to act as a respawn zone
using UnityEngine;
using System.Collections;
public class Respawn : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
other.gameObject.transform.position = Vector3(0, 1, 0);
}
}
}
I’m sure there is something very basic that I am doing wrong, but I am having a hard time figuring out what I should change.
Any help with an explanation about what is wrong would be greatly appreciated. I know its basic stuff, and thats why I want to understand the problem and not just have a quick fix.