Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: KillerCreeper on May 29, 2019, 02:52:04 PM

Title: Raycast Follow Cursor?[SOLVED]
Post by: KillerCreeper on May 29, 2019, 02:52:04 PM
How can I get a raycast to follow the cursor and point in the direction that it is facing? I would use the Mouse Pick action but that is the most inconsistent thing I have ever used before.
Title: Re: Raycast Follow Cursor?
Post by: jeanfabre on May 30, 2019, 02:45:47 AM
Hi,

 MousePick works very well. What is the problem you are having? a raycast can only pick objects with a collider on it, maybe that's the problem?

the cursor not facing anywhere, it's a point on screen, then it's up to you to decide the direction of the raycast from that point, which is usually the camera z axis so I think you mean that you want to raycast in the direction of the camera right?

 Bye,

 Jean
Title: Re: Raycast Follow Cursor?
Post by: KillerCreeper on May 30, 2019, 03:19:00 AM
Hi,

 MousePick works very well. What is the problem you are having? a raycast can only pick objects with a collider on it, maybe that's the problem?

the cursor not facing anywhere, it's a point on screen, then it's up to you to decide the direction of the raycast from that point, which is usually the camera z axis so I think you mean that you want to raycast in the direction of the camera right?

 Bye,

 Jean

It's kind of hard for me to explain but I can try my best. I am applying a Mouse Pick action to the main camera of the player. It is a first-person game, so the the cursor gets locked in place using the set mouse action(I think..).
What the real problem is, is that I think that the raycast is pointing in an extremely weird direction or something.
Whenever the cursor is locked and I look at the terrain, unless it is a short raycast, it'll only get the terrain collider, no matter what other collider I look at. If it's a short raycast, it'll get nothing. When I unlock the cursor, it'll get different game objects but it is very inconsistent. I can be looking in the sky but it still says the terrain, then I move my cursor over a little bit to another part of the sky and it'll say it's getting nothing.
Also, the action is set to every frame and the objects I am trying to get have colliders on them- I just thought I should point that out.

I'm sorry that this is long. I tried my best to explain what is happening. It's just so very weird and confusing to me.
Title: Re: Raycast Follow Cursor?
Post by: KillerCreeper on May 31, 2019, 12:14:03 AM
I managed to get it working with using the raycast action.
Title: Re: Raycast Follow Cursor?
Post by: djaydino on May 31, 2019, 02:23:44 AM
Hi,
Indeed raycast is better for fps.

Here is a video link which uses this :