I'm using a Trigger for a projectile and I'm having trouble getting everything to work properly
OK, so I wanted to use a trigger as the collision checker for this hookshot mechanic I'm making. I've got almost everything, but there's one major problem. The projectile spawns on the player position, and because I was using it as a collider it would bump ito the player and mess with the mechanics. So I wanted to make the projectile a trigger so it wouldn't collide with anything, but now I can't get the OnCollisionEnter2D void to work properly because it's not colliding with things anymore. Does anyone know what command I need to use? I feel like this should work with the right "Collision" word changed into "Trigger"...
void OnCollisionEnter2D (Collision2D coll) {
if (coll.gameObject.CompareTag("Player") == false)
{
rb2d.velocity = new Vector2(0, 0);
thePlayer.transform.position = Vector2.MoveTowards(thePlayer.transform.position, transform.position, flightSpeed);
}
}
Your answer
Follow this Question
Related Questions
OnTriggerEnter happens too late 0 Answers
Destroy object on hover? 1 Answer
How do I make this script play a particle sytem from prefab 1 Answer
End Game (Stop spawning) with OnTriggerEnter or OnCollisionEnter? 0 Answers
4 line code not working! 1 Answer