playMaker

Author Topic: Rewired/Cinemachine Actions discussion  (Read 1883 times)

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #15 on: August 08, 2018, 08:50:20 AM »
Just that when I move the joystick left and right it slightly turns the camera diagonally down. And the values are not like the original input I previously had it all feels off :/

There's no way possible that the Cinemachine integration is responsible for that. If you look at the code, you'll see that only input for the named Action requested is queried. There's no way any value from another Action could possibly be getting mixed in causing it to rotate downward. It sounds to me like your joystick is drifting. The default radial deadzone will not stop a downward drift because the deadzone is based on the total magnitude of the input vector. Once the magnitude goes beyond the threshold, both values from the X and Y axes are used. This is the only way to get a smooth look input that doesn't clamp at the 4 cardinal directions. If you don't like this, change the default deadzone to Axial in the Rewired Input Manager settings.

I also wanted to know when it comes to using unity input override does that play well with Cinemachine script?

The Cinemachine bridge queries the Rewired Player directly for input. It is not affected in any way by Unity Input Override.

Lastly for the cinemachine script to override the player do I attach it to the camera? Let's say if I have more than 1 player in the scene and each has their own free look cam I want to control does the script go attached on the virtual cam?

No. There is no support for multiple Players in Cinemachine. Look at the Cinemachine code. The delegate that is provided in the CinemachineCore class to override to change the input source is a single static delegate. You have only one single global static delegate which can be swapped to change the source of input. That means only one player is possible because Cinemachine has one single delegate which is used as the source of input. The Cinemachine integration is not an enhancement or upgrade to Cinemachine that will make it possible to use multiple Players to control multiple look cameras. That would require significant changes all over the Cinemachine code.

The only thing you can do is to change the Player Id in the inspector or on the static property dynamically to swap which Player is in control of Cinemachine.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #16 on: August 08, 2018, 08:53:50 AM »
If it "feels different" the only thing that would cause that is the code to convert absolute axis values into deltas to work better with the Cinemachine code. The result is the stick is going to be less overly sensitive than before. If you want it to be overly sensitive like it was before, increase the Absolute Axis Sensitivity in the inspector or by using the static property.

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #17 on: August 13, 2018, 05:17:17 PM »
No. There is no support for multiple Players in Cinemachine. Look at the Cinemachine code. The delegate that is provided in the CinemachineCore class to override to change the input source is a single static delegate. You have only one single global static delegate which can be swapped to change the source of input. That means only one player is possible because Cinemachine has one single delegate which is used as the source of input. The Cinemachine integration is not an enhancement or upgrade to Cinemachine that will make it possible to use multiple Players to control multiple look cameras. That would require significant changes all over the Cinemachine code.

The only thing you can do is to change the Player Id in the inspector or on the static property dynamically to swap which Player is in control of Cinemachine.

Thats quite unfortunate,

I'm a newbie programmer at best so it'll be quite hard for me to understand anything made in these scripts especially if its coded by pros like you guys haha. Now It is possible to control multiple freelook cameras with other controllers using Unity's Input system. It's easy and all I had to do was enter the string from the input manager for players 1 and 2. Also, change the camera's layers in the culling section to one different from player 1. I'd really hate to drop the use of ReWired over Cinemachine since Cinemachine is a very important part of the game. What I'll do is just experiment with whatever tools you have given me (Thanks a lot by the way!) and use ReWired's Unity Input Override to use Cinemachine. I should get it to work somehow, Thanks for all your assistance Guavaman! :)

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #18 on: August 13, 2018, 11:57:03 PM »
No. There is no support for multiple Players in Cinemachine. Look at the Cinemachine code. The delegate that is provided in the CinemachineCore class to override to change the input source is a single static delegate. You have only one single global static delegate which can be swapped to change the source of input. That means only one player is possible because Cinemachine has one single delegate which is used as the source of input. The Cinemachine integration is not an enhancement or upgrade to Cinemachine that will make it possible to use multiple Players to control multiple look cameras. That would require significant changes all over the Cinemachine code.

The only thing you can do is to change the Player Id in the inspector or on the static property dynamically to swap which Player is in control of Cinemachine.

Thats quite unfortunate,

I'm a newbie programmer at best so it'll be quite hard for me to understand anything made in these scripts especially if its coded by pros like you guys haha. Now It is possible to control multiple freelook cameras with other controllers using Unity's Input system. It's easy and all I had to do was enter the string from the input manager for players 1 and 2. Also, change the camera's layers in the culling section to one different from player 1. I'd really hate to drop the use of ReWired over Cinemachine since Cinemachine is a very important part of the game. What I'll do is just experiment with whatever tools you have given me (Thanks a lot by the way!) and use ReWired's Unity Input Override to use Cinemachine. I should get it to work somehow, Thanks for all your assistance Guavaman! :)

The only way you could actually make it use separate Rewired Players for each camera is to encode a player id into the string, parse it, and choose the Rewired Player based on that string. (Like Player0_MouseX, split that to find the Player and the Action name). This is ugly and will generate garbage. Either that or have a fixed list of Action names and map each individual Axis name to a Rewired Action and Rewired Player id by creating a lookup table. ("Player0_MouseX" = Player 0, "MouseX".) Neither method is very pretty.

Your example of controlling multiple cameras using Unity's Input Manager could be done just as easily using Rewired. If you have to use multiple Axis names in the Unity Input Manager, you could just as easily use multiple Action names in Rewired. They'd all be controlled by the same Rewired Player. but that's exactly what you're doing using Unity's input system. It's ugly to make a single Player with multiple different Actions to control multiple cameras, but it can certainly be done and is no less functional that using Unity's input manager in the same manner.

I guess I'm going to have to re-do the Cinemachine integration. It will have to be a MonoBehaviour if it requires Axis to Action mappings.
« Last Edit: August 14, 2018, 12:05:14 AM by Guavaman »

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #19 on: August 14, 2018, 12:43:45 AM »
https://www.dropbox.com/s/luqrb6e9nhk2p1e/RewiredCinemachineBridge.zip?dl=0

There's a new bridge. Replace the existing bridge files in Rewired/Integration/Cinemachine.

You have to map Axis names to each Player in the inspector. Each Player id has a list of Action mappings where you must set the Unity axis name and the Rewired Action name. If you have more than one Player, you must use unique axis names for each Cinemachine axis so it can be associated to the Player.

For example:
Player1 Mouse X
Player1 Mouse Y
Player2 Mouse X
Player2 Mouse Y

Then in the inspector, set up 2 Players, and underneath each add the respective mappings:

Player Id: 0
Action Mapping: "Player1 Mouse X" = "Mouse X"
Action Mapping: "Player1 Mouse Y" = "Mouse Y"

Player Id: 1
Action Mapping: "Player2 Mouse X" = "Mouse X"
Action Mapping: "Player2 Mouse Y" = "Mouse Y"

I will probably make a custom inspector for this in the next update, but the next Rewired update will not be for a long time due to some very big changes I'm having to make for IL2CPP Win/OSX.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #20 on: August 14, 2018, 07:09:11 PM »
I've updated the script with full inspector action mapping and a number of other features.

https://www.dropbox.com/s/luqrb6e9nhk2p1e/RewiredCinemachineBridge.zip?dl=0

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #21 on: August 20, 2018, 10:35:30 AM »
I've updated the script with full inspector action mapping and a number of other features.

https://www.dropbox.com/s/luqrb6e9nhk2p1e/RewiredCinemachineBridge.zip?dl=0

Oh wow thanks! I just saw this I'll definitely check this out as soon as I have the time. And once again thank you for all your assistance literally makes me see why this product was worth the money.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #22 on: August 20, 2018, 10:43:48 AM »
I've already released the new update that includes the final new version of the Cinemachine integration. It will be available on the Unity Asset Store most likely this week.

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #23 on: August 20, 2018, 11:07:36 AM »
I've already released the new update that includes the final new version of the Cinemachine integration. It will be available on the Unity Asset Store most likely this week.

Awesome! I'll give you feedback on it as soon as I test it out I know this isn't a priority so I wouldn't want to distract you from whatever roadmap you have planned for ReWired. I really appreciate the time you spent on small integration. Thanks again!

Just one question tho. Does cinemachine API locks you out of using inputs? I see we have to use mouse X and Y. I was giving it some thought and perhaps because me using the mouse x & y through the joystick was the reason it all felt off. I know cinemachine lets you plug in unity's input but i just found it weird you didn't use input instead. You probably had your reasons for that I was just wondering ^_^

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #24 on: August 20, 2018, 11:57:42 AM »
I've already released the new update that includes the final new version of the Cinemachine integration. It will be available on the Unity Asset Store most likely this week.

Awesome! I'll give you feedback on it as soon as I test it out I know this isn't a priority so I wouldn't want to distract you from whatever roadmap you have planned for ReWired. I really appreciate the time you spent on small integration. Thanks again!

Just one question tho. Does cinemachine API locks you out of using inputs? I see we have to use mouse X and Y. I was giving it some thought and perhaps because me using the mouse x & y through the joystick was the reason it all felt off. I know cinemachine lets you plug in unity's input but i just found it weird you didn't use input instead. You probably had your reasons for that I was just wondering ^_^

No you do not have to use mouse X and mouse Y. Those are nothing but names of Actions. You can call them whatever you want. The entire purpose of the integration is to be able to use Rewired, which by definition means you can use any controller type you want. The reason they start "Mouse X" and "Mouse Y" is that is what the Cinemachine camera scripts use for the default action names. They're just defaults.

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #25 on: August 20, 2018, 04:01:02 PM »
Quote
No you do not have to use mouse X and mouse Y. Those are nothing but names of Actions. You can call them whatever you want. The entire purpose of the integration is to be able to use Rewired, which by definition means you can use any controller type you want. The reason they start "Mouse X" and "Mouse Y" is that is what the Cinemachine camera scripts use for the default action names. They're just defaults.

WOOOOW No wonder I using ReWired mouse inputs to control the cameras through joystick instead of using Controller inputs. Alright, I definitely have tons of testing to do I'll definitely do it all as soon as I get the time to. Thanks for the information Guavaman :)

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #26 on: August 20, 2018, 04:30:31 PM »
WOOOOW No wonder I using ReWired mouse inputs to control the cameras through joystick instead of using Controller inputs.

This statement is quite confusing to me. What do you mean by "using Rewired mouse inputs?" If you are using Rewired to control the camera with a joystick, you're using Rewired to control the camera with a joystick. There's no way possible you could be accidentally using the mouse to control a joystick.

In Rewired, there are nothing but:
Actions
Controller Maps

Your Actions can be named whatever you want. You can call them:
Look X
Mouse X
Upside-down Flying Ninja Robot Zombie Pizza from Galaxy X

Regardless of the name, they are all exactly the same.

To use these Actions, you must create some Controller Maps for the different controller types you want to support.

When you create a Controller Map for a Joystick, you are creating bindings between joystick elements and Actions.

When you create a Controller Map for a Mouse, you are creating binding between mouse elements and Actions.

Even if that Action's name was "Mouse X", when you made a Joystick Map using that Action, it's equally as valid as making a Joystick Map with an Action named "Look X." There's absolutely no difference.

If you were using Actions in Rewired called "Mouse X" and "Mouse Y" and making Joystick Maps with those two Actions, that's perfectly valid and will work. You will get the exact same result as if you change the names to "Look X" and "Look Y".

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #27 on: August 21, 2018, 08:34:49 PM »
WOOOOW No wonder I using ReWired mouse inputs to control the cameras through joystick instead of using Controller inputs.

This statement is quite confusing to me. What do you mean by "using Rewired mouse inputs?" If you are using Rewired to control the camera with a joystick, you're using Rewired to control the camera with a joystick. There's no way possible you could be accidentally using the mouse to control a joystick.

In Rewired, there are nothing but:
Actions
Controller Maps

Your Actions can be named whatever you want. You can call them:
Look X
Mouse X
Upside-down Flying Ninja Robot Zombie Pizza from Galaxy X

Regardless of the name, they are all exactly the same.

To use these Actions, you must create some Controller Maps for the different controller types you want to support.

When you create a Controller Map for a Joystick, you are creating bindings between joystick elements and Actions.

When you create a Controller Map for a Mouse, you are creating binding between mouse elements and Actions.

Even if that Action's name was "Mouse X", when you made a Joystick Map using that Action, it's equally as valid as making a Joystick Map with an Action named "Look X." There's absolutely no difference.

If you were using Actions in Rewired called "Mouse X" and "Mouse Y" and making Joystick Maps with those two Actions, that's perfectly valid and will work. You will get the exact same result as if you change the names to "Look X" and "Look Y".

Sorry for the confusion By Mouse X and Y I was referring to the Mouse Axis. I thought ReWired Cinemachine integration only worked with those. I'm well aware that naming conventions don't matter in this case but thank you once again! :)

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #28 on: August 21, 2018, 08:41:30 PM »
WOOOOW No wonder I using ReWired mouse inputs to control the cameras through joystick instead of using Controller inputs.

This statement is quite confusing to me. What do you mean by "using Rewired mouse inputs?" If you are using Rewired to control the camera with a joystick, you're using Rewired to control the camera with a joystick. There's no way possible you could be accidentally using the mouse to control a joystick.

In Rewired, there are nothing but:
Actions
Controller Maps

Your Actions can be named whatever you want. You can call them:
Look X
Mouse X
Upside-down Flying Ninja Robot Zombie Pizza from Galaxy X

Regardless of the name, they are all exactly the same.

To use these Actions, you must create some Controller Maps for the different controller types you want to support.

When you create a Controller Map for a Joystick, you are creating bindings between joystick elements and Actions.

When you create a Controller Map for a Mouse, you are creating binding between mouse elements and Actions.

Even if that Action's name was "Mouse X", when you made a Joystick Map using that Action, it's equally as valid as making a Joystick Map with an Action named "Look X." There's absolutely no difference.

If you were using Actions in Rewired called "Mouse X" and "Mouse Y" and making Joystick Maps with those two Actions, that's perfectly valid and will work. You will get the exact same result as if you change the names to "Look X" and "Look Y".

Sorry for the confusion By Mouse X and Y I was referring to the Mouse Axis. I thought ReWired Cinemachine integration only worked with those. I'm well aware that naming conventions don't matter in this case but thank you once again! :)

Are you saying you were using ReInput.controllers.Mouse to get the values of the mouse directly? Because if you're using Player-Actions, you're using whatever current input device is mapped to those Actions and assigned to the Player whether it be a mouse, joystick, or keyboard.

mrminico

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #29 on: August 21, 2018, 09:11:16 PM »
WOOOOW No wonder I using ReWired mouse inputs to control the cameras through joystick instead of using Controller inputs.

This statement is quite confusing to me. What do you mean by "using Rewired mouse inputs?" If you are using Rewired to control the camera with a joystick, you're using Rewired to control the camera with a joystick. There's no way possible you could be accidentally using the mouse to control a joystick.

In Rewired, there are nothing but:
Actions
Controller Maps

Your Actions can be named whatever you want. You can call them:
Look X
Mouse X
Upside-down Flying Ninja Robot Zombie Pizza from Galaxy X

Regardless of the name, they are all exactly the same.

To use these Actions, you must create some Controller Maps for the different controller types you want to support.

When you create a Controller Map for a Joystick, you are creating bindings between joystick elements and Actions.

When you create a Controller Map for a Mouse, you are creating binding between mouse elements and Actions.

Even if that Action's name was "Mouse X", when you made a Joystick Map using that Action, it's equally as valid as making a Joystick Map with an Action named "Look X." There's absolutely no difference.

If you were using Actions in Rewired called "Mouse X" and "Mouse Y" and making Joystick Maps with those two Actions, that's perfectly valid and will work. You will get the exact same result as if you change the names to "Look X" and "Look Y".

Sorry for the confusion By Mouse X and Y I was referring to the Mouse Axis. I thought ReWired Cinemachine integration only worked with those. I'm well aware that naming conventions don't matter in this case but thank you once again! :)

Are you saying you were using ReInput.controllers.Mouse to get the values of the mouse directly? Because if you're using Player-Actions, you're using whatever current input device is mapped to those Actions and assigned to the Player whether it be a mouse, joystick, or keyboard.

Alright I opened unity up so I can retrace everything I did so there wont be any more confusion. (Sorry in advance  :'( my ReWired terminology is all off)

Heres What I did:

I used a mouse map for the right analog sticks and assigned mouse horizontal and mouse Vertical in the element section. I then assigned the mouse map to the player. At the time I thought only mouse maps would work with the integration.