playMaker

Author Topic: [SOLVED]How to limit the mouse using the action "Follow Mouse"  (Read 420 times)

colpolstudios

  • Full Member
  • ***
  • Posts: 197
    • View Profile
I wish to be able to limit my characters shooting ability, currently, I am using the action follow mouse, based on the position of the main camera.

In order to better improve the current system "https://hutonggames.com/playmakerforum/index.php?topic=20555.msg90096#msg90096" I require some advice and help to implement a better system.

Here is a web link to a playable demo but its an old one: https://simmer.io/@colpolstudios/mechanim-simple-ik

I have yet to update the web player build.

The model looks at a target, this target is using the follow mouse.

I wish to limit the target range both up and down so that the model only moves whilst aiming to a more accurate range.

I have been able to update the entire system, but this aspect requires your valuable help.

Also. I do not remember, how to insert a image on this page, sorry but help needed here as well.

Kind regards

colpolstudios

« Last Edit: July 25, 2019, 04:23:15 AM by colpolstudios »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4518
    • View Profile
    • jinxtergames
Re: How to limit the mouse using the action "Follow Mouse"
« Reply #1 on: July 14, 2019, 06:42:34 AM »
Hi.
i am not entirely sure what you mean.
But after testing the game i think i know what you mean (bare with me if i am wrong)

Follow Mouse will not work with this, you will need to make your own system.

i think you need to do something like this :

(State 1) when right mouse is clicked (State 2) get the mouse x and y.
Also get the current rotation from aim.

Quote
I noticed that 'Get Mouse X and get mouse Y can only be used every frame, i have requested alex to change if possible.
For now you can use Get Mouse Position (Ecosystem) and if you need them separately you can use 'Get Vector 2 XY'
Set in some variables (started X / Started Y)

(state 3)
Get mouse x/y every frame (place in variable current X / current Y)
and use float operator and do 'current - started' (every frame) for x and y and store in variable (X calculated / Y calculated)
You can now do a 'float multiply' to the 'calculated' to adjust the rotation distance
(play around with this to know which value fits best)
after the float multiply use Float operator and do 'aim (x/y/z) + calculated.
and then Set rotation.

I did not test this, but i think this should work.

The float multiply you can manipulate by another fsm so you could make it rotate faster/slower on demand.
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

colpolstudios

  • Full Member
  • ***
  • Posts: 197
    • View Profile
Re: How to limit the mouse using the action "Follow Mouse"
« Reply #2 on: July 15, 2019, 03:37:38 PM »
Thank you for your kind help, however i require the target object to always be a set distance from the main camera.

In the follow mouse action the is a option to contain the mouse to the screen, would it be possible to create a new version, but using a plane attached to the player?

Using the four points of the plane to define the new area to contain the mouse.

Note:To anyone playing around with the first release  "please select IK pass also on the first layer or better results whilst aiming"

Progress is going rather slow, hopefully i will update you all soon.







colpolstudios

  • Full Member
  • ***
  • Posts: 197
    • View Profile
Re: How to limit the mouse using the action "Follow Mouse"
« Reply #3 on: July 17, 2019, 06:43:44 AM »
After a closer look at the new setup. I feel the answer lies in other parts of the setup.

many thanks for your time.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4518
    • View Profile
    • jinxtergames
Hi.
Ok, i will set this topic as solved then.

I you wish still to have more support on this topic, you can edit your 1st post and remove [SOVLED] on the subject
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

colpolstudios

  • Full Member
  • ***
  • Posts: 197
    • View Profile
Re: How to limit the mouse using the action "Follow Mouse"
« Reply #5 on: July 21, 2019, 03:39:49 PM »
Hi.
i am not entirely sure what you mean.
But after testing the game i think i know what you mean (bare with me if i am wrong)

Follow Mouse will not work with this, you will need to make your own system.

i think you need to do something like this :

(State 1) when right mouse is clicked (State 2) get the mouse x and y.
Also get the current rotation from aim.

Quote
I noticed that 'Get Mouse X and get mouse Y can only be used every frame, i have requested alex to change if possible.
For now you can use Get Mouse Position (Ecosystem) and if you need them separately you can use 'Get Vector 2 XY'
Set in some variables (started X / Started Y)

(state 3)
Get mouse x/y every frame (place in variable current X / current Y)
and use float operator and do 'current - started' (every frame) for x and y and store in variable (X calculated / Y calculated)
You can now do a 'float multiply' to the 'calculated' to adjust the rotation distance
(play around with this to know which value fits best)
after the float multiply use Float operator and do 'aim (x/y/z) + calculated.
and then Set rotation.

I did not test this, but i think this should work.

The float multiply you can manipulate by another fsm so you could make it rotate faster/slower on demand.

With the use of the controller tester asset, I set up another way to move the target object for the IK.

I have attached a screenshot image of the actions.

Issues: I would need a way to contain the object to a set distance up, down left and right.

Currently, the target object (sphere) is attached as a child of the main character set forwards from his chest. When I move the right/left joystick it will continue to move according to my input, however, this state is always active.

So when I am no longer aiming, but looking in a new direction, the target object will also move.

Currently, I now have two options mouse or joystick control. The mouse control is still using the follow mouse action.

Within each option, I have a new fsm that disables the looking option whilst shooting, this gives better-aiming results and re-enabled with a second right-click.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4518
    • View Profile
    • jinxtergames
Re: How to limit the mouse using the action "Follow Mouse"
« Reply #6 on: July 21, 2019, 03:48:09 PM »
Hi.
Do you have a reference of a game that uses the system you are trying to setup?
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions