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"))
{
other.gameObject.GetComponent<Rigidbody>().AddForce(Vector3.up*speed);
}
}
}
I have set speed force to 100.
But when player enters the collider, nothing happens. It doesn't tag it.