Question by
ShirazAkber · Mar 14, 2018 at 06:25 PM ·
collisionontriggerenterroll a ball
Not detecting collision
Hello im trying to make the roll a ball game but it does not collect the collectible instead goes through it this is the code im using and also i have checked the "istrigger" still its not being collected.
public class PlayerController : MonoBehaviour {
private Rigidbody rb3d;
public int speed;
private void FixedUpdate()
{
float moveh = Input.GetAxis("Horizontal");
float moveV = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveh, 0.0f, moveV);
rb3d.AddForce(movement * speed);
}
private void Start()
{
rb3d = GetComponent<Rigidbody>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Coin"))
{
other.gameObject.SetActive(false);
}
}
}
Comment
Best Answer
Answer by meat5000 · Mar 14, 2018 at 06:27 PM
private Rigidbody rb3d;
~
void OnTriggerEnter2D
~
Look hard and consider.
~
If you dont get it from that, here's a spoiler. You're going to kick yourself.
O$$anonymous$$G thanks alot bro lol im such a noob sometimes