Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: JonathanBurroughs on April 02, 2014, 02:55:44 PM
-
Hello all,
I've taken a look at this thread here: http://hutonggames.com/playmakerforum/index.php?topic=3085.0
Following it's instructions I've run Set Mouse Cursor at the start of my game to hide and lock the mouse cursor.
However I'm still finding the mouse cursor drifting around in the scene, which makes using Mouse Pick tricky.
Ideally I want the Mouse Pick origin to be the screen centre, to align with a fixed screen position targeting reticule.
Is there a way to set this up?
-
Could you use a raycast from the camera instead? That wouldn't jitter.
-
Yeah, perhaps that's best. I'll swap out my Mouse Picks for Raycasts.
-
Ah. Actually this raises a broader question.
The Raycast action can't be toggled to call every frame. What is the best practice way to make it do so using states and events?
At first I thought I could just fire a ray whenever an action button is pressed, but ideally I'm going to want to be able to check the hit object every frame so I can do things like modify the target reticule appearance to indicate when an interactive object is targeted.
-
Here is what I'll attempt as a first stab:
- FSM on player camera has an event which fires a ray
- Ray detects the target gameobject and declares it as a global variable
- Event waits a short while (<0.1s)
- Event self-triggers
Any interactive gamobjects can compare themselves to the global variable. If they're the same and an action button is pressed then magic can happen.
Similarly my GUI system can evaluate the global variable to see if it should draw the standard or interactive target reticule.
-
Ah, found the Repeat Interval field on the Raycast action, so I don't need the self-triggering event.
Even so it's not working for some reason. Although I can't see why. I've switched on the debug view of the raycast and can't see the beam leaving the camera. So I suspect I've done something fundamentally stupid.
-
Is the repeat interval at either 1 or 2? Is the Distance set to a high number? Are there any colliders it might be running into on the camera or anything?
-
Heh, I wish it was any one of those. I've taken a stab at dabbling with all of them.
- Distance set to both 100 and -1
- Repeat interval set to both 1 and 2
- Tried casting from an empty object with no colliders and still nothing
I might just be doing something so fundamentally wrong that it's broken my entire approach.
-
So I've created a test environment with just a single cube with no collision emitting a debug ray.
(http://i.imgur.com/c8bnhRv.png)
When I run the game the ray doesn't appear in either the Scene or Game viewports. Strange!
-
You need a direction! =)
The vector for direction should be z = 1
-
Haha. That fixed it! Man, I feel so stupid. Thank you, Lane!