Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: rojosedano on March 07, 2012, 05:29:04 AM

Title: raycast point of origin
Post by: rojosedano on March 07, 2012, 05:29:04 AM

Hello, I have two questions:
 1-I have difficulties to adjust the point of origin of the ray in action raycast. It always comes from the same point.

 2-you can make a custom action with javascript?

 thanks














Title: Re: raycast point of origin
Post by: playmakerNewb on March 07, 2012, 08:53:56 AM
How are you determining what your point of origin is?  Are you raycasting from a specific camera?  From a mouse pointer?

I cast rays via the following code.

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

I can't answer question 2 as I don't use javascript.
Title: Re: raycast point of origin
Post by: rojosedano on March 08, 2012, 03:02:00 PM
maybe I have not explained well, sorry for my bad English I am Spanish.
 See the attached image.
Ray always goes from the center of the cube.


I do something wrong?

 thanks
Title: Re: raycast point of origin
Post by: legend411 on March 09, 2012, 11:04:48 AM
You'd probably want to use a Vector3 variable, store the origin object's transform.position in it with the Transform Get Position action, then use the Vector3 Add action to add an offset. Then use that variable in the raycast action's From Position.
Title: Re: raycast point of origin
Post by: Gua on February 11, 2014, 06:54:21 AM
You'd probably want to use a Vector3 variable, store the origin object's transform.position in it with the Transform Get Position action, then use the Vector3 Add action to add an offset. Then use that variable in the raycast action's From Position.
But how do I make that vector face same direction as a cube?
Title: Re: raycast point of origin
Post by: jeanfabre on February 11, 2014, 01:15:09 PM
Hi,

 Yes you can write custom actions in javascript, but I recommand c#, you'll then be able to copy paste from all the existing actions and the one on the wiki and forum.

set the fromGameObject to "none" then the position will be taken in consideration, else it's ignored. that's your problem I think.

bye,

 Jean