playMaker

Author Topic: Raycast Create Object Rotation [SOLVED]  (Read 9327 times)

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Raycast Create Object Rotation [SOLVED]
« on: December 06, 2011, 05:12:48 AM »
I'm making a gun fire a ray, get the hit info then create a particle system at the hit position. All that works great, but it won't create the particle system at the right surface normal angle. I thought it was broken at first then realised, shouldn't it be a rotation (0, 180, 0) instead of a vector (0, 1, 0)? Not sure if my terminology is right there...

So it's been working but the created object (particle system) is created on an angle of no higher than 1 or so, so it doesn't appear to change.

Is this how it's supposed to work? Should I put an extra action in there before creating the object to convert the normal to an angle?
« Last Edit: December 07, 2011, 06:55:58 AM by FractalCore »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast Create Object Rotation
« Reply #1 on: December 07, 2011, 02:22:48 AM »
Hi,

 I think you are getting confused with a "direction" vector and a vector representing angles in degrees.

 A direction vector doesn't give you the angle, it gives you exactly this, the direction, so vector(0,1,0), means it's going straight up.

You can compute angles between two vectors:

http://unity3d.com/support/documentation/ScriptReference/Vector3.Angle.html


Bye,

 Jean

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Raycast Create Object Rotation
« Reply #2 on: December 07, 2011, 02:40:31 AM »
That's what I thought. But what's the use of finding a normal from a ray hit if it can't be applied in this way.

I saw someone else here... http://hutonggames.com/playmakerforum/index.php?topic=725.0
...asking how to use Raycasting and alexchouls said...

"You can store the position and normal generated by the raycast or collision and use those with Create Object to make a bullet hole object in the right place. Use the hit normal to rotate the created object."

That's exactly what I'm trying to do. Does the Hit Normal work for setting the rotation of a created object like he said?

FractalCore

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 100
Re: Raycast Create Object Rotation
« Reply #3 on: December 07, 2011, 06:55:23 AM »
http://hutonggames.com/playmakerforum/index.php?topic=725.0

I followed the tutorial in that post. Now my stuff works, thanks.

I thought I was on top of raycasting, didn't need to use a new action to simplify the process of aiming the ray, I used the old, more "complicated" one. Where things break down is the part about using a Vector3 Operator AND a Look At action to basically convert the normal info into something usable.

I worked out what it's doing, add 1 from the normal to where ever the hit position is, in the direction of the normal, then tell it to look at that position, I could have worked at it all week and not come up with that.

That part of raycasting could definitely use some simplification. The other parts just take a little practice and there is instructions to explain it, not this normal to rotation part.

If it's possible could the Get Raycast Hit Info action also have X Y Z rotation values that could then be plugged straight into a Set Rotation or a Create Object, by-passing the need for the Vector3 Operator and Look At actions. That's how I assumed it would naturally work going by how the rest of Playmaker has been working for me so far.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3999
  • Official Playmaker Support
    • LinkedIn
Re: Raycast Create Object Rotation [SOLVED]
« Reply #4 on: December 11, 2011, 12:12:56 AM »
That makes sense. I'll add Rotation to Get Raycast Hit Info to the next update. Thanks for the suggestion!

neroki

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Raycast Create Object Rotation [SOLVED]
« Reply #5 on: February 25, 2012, 08:23:52 AM »
That makes sense. I'll add Rotation to Get Raycast Hit Info to the next update. Thanks for the suggestion!

Was this added?

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: Raycast Create Object Rotation [SOLVED]
« Reply #6 on: June 22, 2013, 02:13:46 PM »
I don't think so, and it would be nice ;)

robosaru

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Raycast Create Object Rotation [SOLVED]
« Reply #7 on: September 08, 2014, 10:53:14 AM »
Was Rotation to Get Raycast Hit Info ever added?

dblincoeii

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Raycast Create Object Rotation [SOLVED]
« Reply #8 on: March 04, 2019, 11:33:13 AM »
Has this been added?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast Create Object Rotation [SOLVED]
« Reply #9 on: March 05, 2019, 12:37:20 AM »
Hi,

 no, but I'll work on an action to do that, so that we don't change the action, but simply create a convenient action to rotate an object based on a direction, which will server many more purpose as a result.

 Bye,

 Jean

dblincoeii

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Raycast Create Object Rotation [SOLVED]
« Reply #10 on: March 05, 2019, 09:16:41 AM »
Thanks.  I need my objects to raycast towards a camera that moves.  The object needs to remain stationary (and not rotate towards camera).  Will this solve?  Ideas?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast Create Object Rotation [SOLVED]
« Reply #11 on: March 27, 2019, 03:23:38 AM »
Hi,

there you go a new action to get the rotation of a direction: https://hutonggames.com/playmakerforum/index.php?topic=20306.0

as for your last question, I am not sure I fully understand your concern. Raycasting can be performed against a camera or an arbitrary position and direction. If the camera moves, you need to perform the raycast every time the camera move to recompute the results, that's it I guess.

Bye,

 Jean