is the Character Controller a Collider?
Hello, I'm having a simple issue but I'm not sure how to resolve it.
I have an "EnemySpawnTrigger", when the player enters the trigger, an enemy prefab is instantiated.
public class EnemySpawnScript : MonoBehaviour {
public GameObject EnemyPrefab;
public Transform EnemySpawnZone;
void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag("Player"))
{
Instantiate(EnemyPrefab, EnemySpawnZone.position, EnemySpawnZone.rotation);
}
Destroy(this.gameObject, 0.5f);
}
} The problem is, my "FPSController" has a "Capsule Collider (isTrigger)" attached to it, it has a smaller radius than the "outline of the Character Controller".
Basically, when I enter the trigger, the "outline of the Character Controller" instantiates one prefab. Then, a split second later, the inner "Capsule Collider" instantiates a second prefab. (Unwanted)
The reason I'm using the "Capsule Collider" is for Parenting the Player with an elevator/ platform system. So, I would like to keep it there if possible.
Any solutions? Any help would be greatly appreciated, Thanks!
I would suggest finding a way to get your elevators to work without the second capsule collider. Are you sure you can't accomplish whatever you're using it for with just the primary collider?
Hi, thanks man! So the "Character Controller" is the primary collider? I was told before that it is not a collider and I need to attach an additional collider. Prob shouldn't have listened to that guy haha. I'll try what you said, Thanks!
Answer by Namey5 · Apr 04, 2017 at 06:09 AM
As far as I can tell, the Character Controller is not part of the Collider class, however it is an extension of it; as such collider elements will still work regardless.
Thanks for your reply! I made some simple changes to my script & it's working fine now without the additional collider. Cheers!
Your answer
Follow this Question
Related Questions
My code is instantiating many prefabs, i only want one. 1 Answer
instantiated prefab doesn't follow spawn rotation 1 Answer
Call function for instantated prefab. "Object reference not set" 1 Answer
Simple Prefab Instantiate "(Clone)" Question 3 Answers
Instantiate and destroy an object with the same key 1 Answer