- Home /
Problem in Raycast when Gameobject collides
Hi!I'm creating a game like TempleRun and I have this First Person Controller in my scene, where it has a a terrain hugging code and a collision code for collecting pickups.
My problem is, every time I collided with the pickups, my first person controller raycasting in the pickups that's causes my FPS to slant. (see the pic where there are blue drawline of raycast)
Here is my code for terrain hugging.
void terrain_hug()
{
RaycastHit hitA;
if(Physics.Raycast(transform.position + transform.forward, -transform.up, out hitA))
{
RaycastHit hitB;
if (Physics.Raycast(transform.position - transform.forward, -transform.up, out hitB))
{
transform.forward = (hitA.point - hitB.point) * Time.deltaTime;
}
}
}
Answer by ddulshan · Feb 08, 2015 at 03:45 AM
What are you using Raycast for? Are you using Raycast to pickup objects? If so, try making the Trigger/Collider of the object a little larger than the Original object.
I'm using raycast for terrain hugging of my character.
BTW, the problem was gone after I add rigidbody to my character and set collision detection to continous.
Answer by tacticz_03 · Feb 08, 2015 at 11:42 AM
add rigidbody to character and set collision detection to continous.
Your answer
Follow this Question
Related Questions
orbiting mouse controlled camera goes thru terrain 3 Answers
Raycast not colliding with selected layer 0 Answers
Camera raycast? 2 Answers
Modifing an Enum value by a String? 2 Answers
Drag gui text and drop it on 3d object. 0 Answers