playMaker

Author Topic: How do you detect only first object hit on a raycast?  (Read 1235 times)

smiffy

  • Junior Playmaker
  • **
  • Posts: 54
How do you detect only first object hit on a raycast?
« on: April 08, 2019, 06:46:32 AM »
Hi there,

I'm trying to use raycast to place an object on the ground with some success, I have the object stepping up and down over ground objects. However if there are two objects on the ground, (ie a floor plane and a step) the object flickers between the two.

How do I get the raycast to stop at the first object it hits and ignore the one underneath?

Thanks, Matt.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How do you detect only first object hit on a raycast?
« Reply #1 on: April 09, 2019, 08:52:07 AM »
Hi.
Can you show the issue in a video?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How do you detect only first object hit on a raycast?
« Reply #2 on: April 09, 2019, 01:32:49 PM »
A: Set the raycast to go to next state after it found something (do not use every frame). That might do the trick. The next state, you do the thing, then return to checking. If you need constant checks, you can also build a loop manually. Use two identical states with rays, and a wait action in each, plus finished events. You can also put the wait between them etc.