- Home /
Question by
rahulpatil6220375 · May 13, 2019 at 10:30 AM ·
physicsraycast
when my player touch the obstacle then going inside obstacle
when i m press arrow(key) then player touch obstacle
float maxdistance =0.54f;
private RaycastHit hit;
public float speed = 10f;
public bool moove;
private void FixedUpdate()
{
Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 3, Color.green);
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out this.hit, maxdistance))
{
if (hit.collider.gameObject.tag == "Obstacles")
{
moove = false;
}
}
}
Output: ][1]][1] when i m increase maxdistance should be notperfect
float maxdistance =1.25f;
Comment
Your answer
Follow this Question
Related Questions
Raycasting 1000 times 1 Answer
Is there a limit on the distance of raycast? 2 Answers
Physics.SphereCastAll with triggers 1 Answer
Raycasting to the bottom side of a plane? 2 Answers
Physics.CapsuleCast Help 1 Answer