playMaker

Author Topic: raycast point of origin  (Read 3960 times)

rojosedano

  • Playmaker Newbie
  • *
  • Posts: 15
raycast point of origin
« 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















playmakerNewb

  • Playmaker Newbie
  • *
  • Posts: 15
Re: raycast point of origin
« Reply #1 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.

rojosedano

  • Playmaker Newbie
  • *
  • Posts: 15
Re: raycast point of origin
« Reply #2 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
« Last Edit: March 08, 2012, 03:05:13 PM by rojosedano »

legend411

  • Playmaker Newbie
  • *
  • Posts: 6
Re: raycast point of origin
« Reply #3 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.

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Re: raycast point of origin
« Reply #4 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: raycast point of origin
« Reply #5 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