Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Andorix on November 25, 2021, 11:17:06 AM

Title: Follow Mouse - Separate Camera
Post by: Andorix 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  :)
Title: Re: Follow Mouse - Separate Camera
Post by: djaydino 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)
Title: Re: Follow Mouse - Separate Camera
Post by: Andorix 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.
Title: Re: Follow Mouse - Separate Camera
Post by: djaydino on November 30, 2021, 01:37:39 PM
Hi.
Sorry, this one should fix the issue (see attachment below)
Title: Re: Follow Mouse - Separate Camera
Post by: Andorix on December 01, 2021, 12:59:14 PM
djaydino thanks so much! it works!  ;D