# Player tag does not respond to AddForce

I have a player with rigidbody and it has a tag as Player .

I have set a sphere collider as trigger with script

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Addforce : MonoBehaviour {

public int speed;

void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("Player"))
{
}
}


}

I have set speed force to 100.

But when player enters the collider, nothing happens. It doesn't tag it.

• Please post the script code as code and not as a screenshot. – Galandil Mar 19 '18 at 21:51
• I see you have a Rigidbody First Person Controller script attached. It's possible that this is overriding the physics inputs from other sources. Can you share some details of this script? – DMGregory Mar 19 '18 at 22:22

Since the sphere is a trigger, you need to use OnTriggerEnter(Collider other) instead of OnCollisionEnter.

OnCollisionEnter, OnCollisionExit and OnCollisionStay are called when both objects' colliders are not triggers.

Moreover, you should specify that the force added is an impulse. You should do this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Addforce : MonoBehaviour {

public int speed;

void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{

• @Wildfire why you had to uncheck isTrigger? OnTriggerEnter would never fire if both objects are not a trigger. – Galandil Mar 19 '18 at 22:28