playMaker

Author Topic: Follow Mouse - Separate Camera  (Read 111 times)

Andorix

  • Playmaker Newbie
  • *
  • Posts: 4
Follow Mouse - Separate Camera
« on: November 25, 2021, 11:17:06 AM »
Hi, in my 3D project I have 2 Cameras working simultaneously (Main camera and Overlay camera):

- Main camera follows my 3rd person character, controlled using joystick (using a mouse to click and drag the joystick)
- Overlay camera shows only the mouse, using culling mask. I have hidden the real mouse cursor, then made a 3D game object and used the "Follow Mouse" action to replace the cursor with my object.

WHY:
Because when the Main Camera follows my character it also affects the mouse in 3D space. The mouse has a trail (particle system) which is unwantedly affected when my character + main camera move. That's why I decided to make a separate static camera, and have the mouse cursor show up only there.

THE PROBLEM:
"Follow Mouse" action restricts the mouse object to the Main Camera. I solved this by untagging the main camera as "MainCamera", and because the overlay camera is also tagged "MainCamera", "Follow Mouse" automatically sends the object there. Now the mouse object moves within the overlay camera. BUT then my character control, joystick etc becomes buggy because the main camera isn't tagged as "MainCamera" anymore. I think it needs to stay tagged like this.

HOW?:
How do I get "Follow Mouse" to restrict the cursor to a camera other than Main Camera (Camera.main)? I want my Main Camera to remain tagged as main, but for "Follow Mouse" to reference my overlay camera instead, and have the cursor constrained there. I think I should tag the overlay cam as something else and have "Follow Mouse" script reference that, but I wasn't successful in changing the script.

Sorry about the length, would really appreciate some help  :)
« Last Edit: November 29, 2021, 03:08:25 AM by Andorix »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6492
    • jinxtergames
Re: Follow Mouse - Separate Camera
« Reply #1 on: November 30, 2021, 10:12:40 AM »
Hi.
I have updated the 'Follow Mouse' so you can set a camera as target see attachment below (renamed it to Follow Mouse 2 to avoid conflicts)

Edit : removed the package sind it had errors)
« Last Edit: November 30, 2021, 01:38:17 PM by djaydino »
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Andorix

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Follow Mouse - Separate Camera
« Reply #2 on: November 30, 2021, 12:45:47 PM »
Hey djaydino thanks! Unfortunately it isn't working atm...

- Getting error message: "No Camera or MainCamera defined!" and then the scene self-pauses.
- It doesn't matter if I select Main Camera or overlay camera (MouseCam), both give the same error. I tried changing the MouseCam tag to something else than "MainCamera", still won't work.
- Original "Follow Mouse" action still works when enabled (defaults to Main Camera like before).

I attached a screen shot to illustrate the problem.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6492
    • jinxtergames
Re: Follow Mouse - Separate Camera
« Reply #3 on: November 30, 2021, 01:37:39 PM »
Hi.
Sorry, this one should fix the issue (see attachment below)
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

Andorix

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Follow Mouse - Separate Camera
« Reply #4 on: December 01, 2021, 12:59:14 PM »
djaydino thanks so much! it works!  ;D