playMaker

Author Topic: Raycast Normal...How do I use it?? [SOLVED]  (Read 3815 times)

SeanC

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Raycast Normal...How do I use it?? [SOLVED]
« on: March 04, 2013, 05:15:24 PM »
Hey all,

So im attempting to get a footprint system working, where i spawn a piece of geometry for the foot on each step, and I've run into a small snag. My idea was to use a raycast to get the "hit point" of the ground for the position and the  "normal" for the angle of the ground. This way, I could spawn the footprint where I need it, and rotate it to be at the same rotation as the ground that was stepped on.

However, when I do this, the footprint only marginally rotates, often in the wrong direction. Do I need to do something with the "normal" info in order to get rotation values out?

How do I use the "normal" information acquired from the raycast? I tried using a "Look At" action on the spawned with the "normal" being the transform, but it just seems to marginally rotate it in the wrong direction.

Any thoughts?
Im happy to post screen caps if i wasnt clear enough.


Thanks!
Sean
« Last Edit: March 05, 2013, 12:34:35 PM by SeanC »

greg

  • Junior Playmaker
  • **
  • Posts: 68
    • View Profile
Re: Raycast Normal...How do I use it??
« Reply #1 on: March 05, 2013, 10:38:53 AM »
I'm also wondering this.

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: Raycast Normal...How do I use it??
« Reply #2 on: March 05, 2013, 11:01:54 AM »
I'm sorry for the poor quality, but I'm in a bit of a hurry here. Consider it a makeshift solution. I used the script in a fps for decals when I was very new to both unity and playmaker. Just pop in the normal in the direction input and it should align the gameObject to the direction. If it's facing the wrong direction, just use a rotate action right after it (depending on the direction of your gameObject you'll neeed to rotate it another 90, 180 or 270 degrees).
Best,
Sven

SeanC

  • Junior Playmaker
  • **
  • Posts: 60
    • View Profile
Re: Raycast Normal...How do I use it??
« Reply #3 on: March 05, 2013, 12:34:08 PM »
And that is why I love the Playmaker community. That did the trick!

Kiriri, thanks a lot for the script. If you're ever in the LA area let me know and Ill buy you a drink.

Sean

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Raycast Normal...How do I use it?? [SOLVED]
« Reply #4 on: March 05, 2013, 12:37:25 PM »
I'm going to have to look at this because having footprints in some spaces is a must (such as sand, after you've walked through a pool of water or gunge, walking through snow)

Though, even though it's been solved, a workaround i was actually thinking of when i first read the post would be to add in a collider object to the bones of the feet to use as a trigger... and then if it's parented to the bones, whenever a food hits the ground you could tell it to spawn a footprint (also you could add in a sound effect.)

But, that is probably not a "best practice" thing... but hey, everything is a learning experience, eh?