Playmaker Forum

PlayMaker Help & Tips => VR Help => Topic started by: BDFgames on November 21, 2016, 08:29:54 AM

Title: Problem with raycasting from child of controller
Post by: BDFgames on November 21, 2016, 08:29:54 AM
Hi there. I've got a problem where raycasting from a game object (specifically, a gun model's bullet spawn point) always seems to use the localspace coordinates, the result of which is that the ray's origin is always 0, 0, 0 (the centre-floor of the Vive play area).

It doesn't seem to matter if I try to use the bullet spawn point as a "hardcoded" Game Object or create a Game Object variable and refer to that, I just can't seem to get it to draw the ray from the actual Game Object -- it always draws it from the floor.

Even weirder, I seemed to "fix" this problem a week ago in one scene (by accident -- I have no idea what I did, but it seemingly started working as you'd expect it to), but when I copy the exact same SteamVR camera rig into a new scene, the origin problem occurs again.  :S

I know this has to be user-error on my part, but I'm stuffed if I can figure out what I'm doing wrong.

Any hints or tips gratefully received. Thanks in advance for your help.  :)
Title: Re: Problem with raycasting from child of controller
Post by: BDFgames on November 27, 2016, 09:06:28 PM
Please forgive the bump. I take it no one's seen this problem before?  :(

Here's a screenshot, in case it helps.
Title: Re: Problem with raycasting from child of controller
Post by: jeanfabre on November 28, 2016, 03:16:42 AM
Hi,

 can you show your raycasting action setup?

how do you compute the direction itself?

Bye,

 Jean
Title: Re: Problem with raycasting from child of controller
Post by: BDFgames on November 28, 2016, 03:47:04 AM
Hi Jean. Thanks for your help.  :)

Here are a few screenshots of the FSM, action and relevant Game Objects. Hope this gives some context.
Title: Re: Problem with raycasting from child of controller
Post by: jeanfabre on November 28, 2016, 04:00:22 AM
Hi,

 ok, thanks. so you do indeed have "Self" turned on, so this will be using the direction 0,1,0 from that "bullet spawn point".

 if that's not what you want, then you first need to compute the direction prior using this action, and turn the space property to "world", then you can fire a ray to any position, regardless of the local space.

Bye,

 Jean

Title: Re: Problem with raycasting from child of controller
Post by: BDFgames on November 28, 2016, 04:09:28 AM
Hi Jean.

I think we're talking about different things. Both the ray and the bullet objects the gun fires (as a visual player aid) go the correct direction--it just starts (origin) on the floor instead of at the Bullet Spawn Point object. The ray is essentially in parallel with the line it should be on.

Unity seems to believe the Bullet Spawn Point object is on the centre-ground of the Vive play area instead of where it's actually located, as the child of the gun object.  :S

And, as mentioned, this exact same setup works perfectly in another scene, with the bullet objects and the ray spawning at the correct point--and I copied this rig from that scene into this new scene as-is!

I seriously cannot see any reason why it is using the wrong origin. It's very weird.  :S
Title: Re: Problem with raycasting from child of controller
Post by: jeanfabre on December 02, 2016, 03:15:31 AM
Hi,

 it's too bad I don't have a vive to test this on...

I would do the following: put some dummy sphere where you think things are so that visually you know where your positions and directions are, it helps figuring out what's wrong for me when I am in a case like that.


Bye,

 Jean
Title: Re: Problem with raycasting from child of controller
Post by: BDFgames on December 02, 2016, 05:40:51 PM
Thanks, Jean. Yes, that's essentially how I figured out what was going on.

I still haven't figured out why it happens, but I've at least figured out what I need to do to fix it when it does, and I've now streamlined that process so it's far less arduous than it was.  :)

Thank you for trying to help, anyway.

And, on a side note, I want to thank you for all the many, many posts and tools I've found from you around the Web and on the Ecosystem—you've made learning the ropes with Playmaker 10,000 times easier.  :)

Cheers!
Mark
Title: Re: Problem with raycasting from child of controller
Post by: jeanfabre on December 13, 2016, 04:04:33 AM
Hi,

 You're welcome, this is actually produced with your license purchase, so you should thank Alex Chouls and HutongGames as well :)

Bye,

 Jean
Title: Re: Problem with raycasting from child of controller
Post by: westingtyler on April 01, 2017, 02:47:59 PM
how do we find alex chouls and hutong to thank them as well? Alex's twitter seems to have never been posted to.
Title: Re: Problem with raycasting from child of controller
Post by: jeanfabre on April 05, 2017, 01:48:33 AM
Hi,

Alex Chouls twitter account is hutongGames twitter account (https://twitter.com/HutongGames) so you can thank him there, he's also on this forum as a member (http://hutonggames.com/playmakerforum/index.php?action=profile;u=3) of course :)

 Bye,

 Jean