playMaker

Author Topic: Raycast; Problems with small objects  (Read 2235 times)

Maxi

  • Playmaker Newbie
  • *
  • Posts: 41
Raycast; Problems with small objects
« on: September 06, 2016, 07:34:43 PM »
Hi everybody,

I'm working with a Raycast (or 3D at all) for the first time and so far everything worked out just fine. I am working first person, built a door which I can open and close per mouseclick, a closet etc.
But now I encountered a problem: I created a small key which I want the player to be able to pick up but the raycast fails to hit it about 80% of the time. Sometimes it works but most of the time I need to click on it repeatedly. Also I have set all the surrounding objects to the 'ignore raycast-layer.
I have attached a picture of my raycast-settings.

Is there a way to make the raycast more sensible or are my settings wrong?
Also: How does the direction vector work? Right now I use it in a 'boolish' kind-of way, just set Y and Z to true...
Also²: The debugging doesnt seem to work either, I cant see any line.

Thanks in Advance

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Raycast; Problems with small objects
« Reply #1 on: September 06, 2016, 08:28:59 PM »
Hi,
maybe you can make the collider bigger and if it is a meshcollider make it a box collider
On the collider adjust the size and center as needed.

Maxi

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Raycast; Problems with small objects
« Reply #2 on: September 07, 2016, 05:09:05 AM »
Hi djaydino,

I thought about this too but even with a big box-colider the raycast hardly hits the object. Right now I tried to cast it from the first-person-camera rather than the controler itself but it doesnt change anything (makes it worse actually). I am thinking that it has to have something to do with the vector values I use but I cant figure out how to fine-tune them.

But thanks for your reply.

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Raycast; Problems with small objects
« Reply #3 on: September 07, 2016, 12:59:26 PM »
The raycast should work 100%, its definitely not set up properly.

If you are setting it to Y and Z as 1, you are emitting forward and up at a 45 degree angle. Try emitting from the camera (assuming you want to interact with something that is in the middle of the screen) with the direction as X0 Y0 Z1 (forward)

ps: The debugging should totally work, but only in scene view, do you not see it?

Maxi

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Raycast; Problems with small objects
« Reply #4 on: September 07, 2016, 01:12:55 PM »
The raycast should work 100%, its definitely not set up properly.

If you are setting it to Y and Z as 1, you are emitting forward and up at a 45 degree angle. Try emitting from the camera (assuming you want to interact with something that is in the middle of the screen) with the direction as X0 Y0 Z1 (forward)

Thanks for the response. I indeed changed the parameters to exactly what you propose earlier today and it works better. I initially used the Y axis because i had attached the ray to the character-controller itself and not the camera and it couldnt find things above me.
It still doesnt work perfectly but I guess I have to tinker with the box-colider sizes to make it work.

ps: The debugging should totally work, but only in scene view, do you not see it?

Thank you for this hint, it actually does work. I use to maximize game-view when I test so I didnt notice that. Though the description is kind of confusing, it says: "Check Debug and Enable Gizmos to see the ray in the Game View." This seems to be wrong.

Anyhow thank you very much! :)