playMaker

Author Topic: Raycast from Script  (Read 3000 times)

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Raycast from Script
« on: July 08, 2013, 09:02:25 PM »
Hey All,

When it comes to scripts to playmaker does anyone know a way to get the raycast info from a script? I am using 2D platformer and it uses its own raycast in the scripts for its character and I need playmaker to identify when the character is hitting different gameObjects.

Thanks!
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast from Script
« Reply #1 on: July 09, 2013, 02:53:51 AM »
Hi,

 if your script expose publiv variables, not a problem, simply use "get property" action. Else, can you give a snippet of your script so that we see what's there, then I'll be able to provide some variants.

bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Raycast from Script
« Reply #2 on: July 09, 2013, 03:11:44 AM »
Okay here is a section with the raycast, I set it to get property and I believe "name" is the information for raycast but it only gives me an int that says 9 but the script has multiple different raycasts shooting off.

Code: [Select]
public class RaycastCollider {

public Transform transform;
public Vector3 offset;
public float distance = 1;
public RC_Direction direction;
private Vector3 staticOffset;

                public bool IsColliding() {
return Physics.Raycast (transform.position + transform.localRotation * offset, transform.localRotation * GetVectorForDirection(), distance);
}

public RaycastHit GetCollision() {
RaycastHit hit;
Physics.Raycast (transform.position + transform.localRotation * offset, transform.localRotation * GetVectorForDirection(), out hit, distance);
return hit;
}

Thanks Jean
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast from Script
« Reply #3 on: July 09, 2013, 03:15:21 AM »
Hi,

 this is not a behavior? that's going to be a little more tricky then. either this script will need to implement playmaker API, to fire events or set Fsm values directly, or else the manager of this class, could expose a public property that the action "get property" can get at.

bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Raycast from Script
« Reply #4 on: July 09, 2013, 03:34:39 AM »
Jiminy...sounds complex... any suggestions on what you approach you would consider the best and where I can get started on it??
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Raycast from Script
« Reply #5 on: July 09, 2013, 05:05:23 AM »
hi,

 it's not complex at all actually :) it really depends your need, but I always tend to simply fire global events, that's the easiest integration you can do within scripts to talk to playmaker.

 so, in your script, when you want to tell something to playmaker Fsm's, simply use.


Code: [Select]
PlayMakerFSM.BroadcastEvent ("PHOTON / LEFT LOBBY");
if you need to pass values, simply fill in the event data prior firing.

you can study my playmaker Photon bridge scripts, they feature a lot of these.

for example: "PlayMakerPhotonProxy", line 498, I fill in data before broadcasting.

Code: [Select]
Fsm.EventData.StringData = stringData;

PlayMakerFSM.BroadcastEvent(globalEventName);

not that "Fsm" is a reference to any fsm you want, so you could pick the first one available or expose a public variable in your component that let's ou point to a fsm "manager" or some sort.

bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Raycast from Script
« Reply #6 on: July 09, 2013, 05:25:16 AM »
Thanks Jean! I will check out the playmakerphotoroxy for these examples
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez