I’ve object with rigid body and capsule collider and I want to move it a few meters, but also make it stop at the first collider on the way. I need this to my player movement script.
thank you in advance for all the answers.
I’m not very good at English, so I use the translator.
You can use a CollisionEnter/triggerenter
private void Update()
{
if(!stopped)
{
transform.position = Vector3.MoveTowards(transform.position, yourTarget.position, speed);
}
}
private void OnCollisionEnter(Collision collision)
{
stopped = true;
}
Ok, I solved it. I used Rigidbody.Sweep Test and everything works!