playMaker

Author Topic: Face cast - like raycast, but casts a square  (Read 846 times)

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Face cast - like raycast, but casts a square
« on: March 24, 2014, 06:30:01 AM »
Hi,

Is it possible to do a Facecast, that would work exactly like Raycast Action, but casted Faces with custom size, instead of rays or spheres?

The only thing: there should be 2 HitPoint variables: One of them should point to actual intersection of the Face and geometry it hit. The other variable should point to the center of the Face in the moment of hit.

Thanks!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Face cast - like raycast, but casts a square
« Reply #1 on: March 24, 2014, 06:37:03 AM »
I don't see anything in the Unity Scripting Reference for a facecast, otherwise we could just make an action for it. Is it some custom thing you have used before?

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Re: Face cast - like raycast, but casts a square
« Reply #2 on: March 24, 2014, 07:22:33 AM »
Yes, but not in Uniy. For camera anti-wall clipping. Every frame, I casted a face. If it collided with a wall, the camera was moved on local Z axis to the center of the face.

The point was, that if you did it on raycast, the camera ended up in the wall anyway, if the angle of hit was very small (see picture attached). This is caused by NearClip distance - the larger it is, the bigger the problem.

If Unity doesn't have this, I'll just work aroud it, with 4 raycasts or something. Unless somebody already figured it out and wants to share :)

Thanks!
« Last Edit: March 24, 2014, 08:06:19 AM by Kubold »