playMaker

Author Topic: Raycast giving DID HIT when the object that was hitted has no longer collision  (Read 2581 times)

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
1. I do raycast over a layer
2. Object that has been hitted get triggered
    2a. I stop raycasting
    2b. I disable the collision of the object that has been hitted (Enable collider action). I have veryfied the collision is no longer active
3. I display some text
4. Do raycast again (ray is exactly in the same position, just hitting same object) giving positive Did hit

Should this be happening?

I can fix it if i set a different layer so raycast is no longer afecting in point 2b
« Last Edit: August 20, 2018, 03:26:57 PM by miguelfanclub »

miguelfanclub

  • Full Member
  • ***
  • Posts: 165

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
hi.
Try putting a next frame event in between (after disabling the collider)
The real disabling might happen slower that the next raycast (within the same frame)

This is a unity thing btw, you would have the same result if you would code in C#

it has to do with the update types
« Last Edit: August 25, 2018, 12:20:55 AM by djaydino »

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
Thanks, but is another issue as the weird thing is that while i display the text after the first hit, i need to press space to continue and then the raycast come up again hitting on the object that has no collision and giving a positive hit (while the text is displayed I can see the object has no collision in the inspector)




djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Hi.
That is strange indeed.

Is it the standard "Raycast" action that you are using?

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
Im using raycast 2

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Hi.
I cant really test now..

For testing :

Can you try to do the 2nd raycast from a different state (the same way as the 1st one)
So after disable do raycast again but from a different state.

Reason : maybe the raycast2 data did not reset when going back to the state/action

does it work with the standard raycast? (you probably need to no hit event, but just for testing when hitting :) )

I will test myself when i get home tomorrow or monday