playMaker

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

smiffy

  • Junior Playmaker
  • **
  • Posts: 54
    • View Profile
How do you detect only first object hit on a raycast?
« on: April 08, 2019, 03: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: 4106
    • View Profile
    • jinxtergames
Re: How do you detect only first object hit on a raycast?
« Reply #1 on: April 09, 2019, 05:52:07 AM »
Hi.
Can you show the issue in a video?

Thore

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: How do you detect only first object hit on a raycast?
« Reply #2 on: April 09, 2019, 10:32:49 AM »
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.