playMaker

Author Topic: Raycast Follow Cursor?[SOLVED]  (Read 611 times)

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Raycast Follow Cursor?[SOLVED]
« 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.
« Last Edit: June 05, 2019, 01:51:34 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15489
  • Official Playmaker Support
    • View Profile
Re: Raycast Follow Cursor?
« Reply #1 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

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Re: Raycast Follow Cursor?
« Reply #2 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.
« Last Edit: May 30, 2019, 03:22:18 AM by KillerCreeper »

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
    • View Profile
Re: Raycast Follow Cursor?
« Reply #3 on: May 31, 2019, 12:14:03 AM »
I managed to get it working with using the raycast action.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6182
    • View Profile
    • jinxtergames
Re: Raycast Follow Cursor?
« Reply #4 on: May 31, 2019, 02:23:44 AM »
Hi,
Indeed raycast is better for fps.

Here is a video link which uses this :