playMaker

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

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Rewired/Cinemachine Actions discussion
« on: July 29, 2018, 12:17:06 AM »
Hello everyone!

lately, I've been using Cinemachine and ReWired actions for a multiplayer game I'm working on. I've hit an unfortunate dead end while using both of these plugins and cannot control Cinemachine's free look cam using ReWired axis. I also cannot get the proper usage of Get Axis Vector for movement relative to camera position.

Now as an alternative I tried using ReWired Unity Input Override addon and it actually worked for the Get axis vector action (And all other PM Input actions). Although I got the Get Axis Vector action to work I faced the problem of not being able to assign multiple controllers. There was no way for me to replicate the get axis vector action using ReWired actions so I gave up on that.

As for Cinemachine, the override addon had no effect. I read on ReWired docs that The input script must make all calls by using the shortened form of "Input.GetAxis" instead of the fully-qualified form "UnityEngine.Input.GetAxis". Scripts that use fully-qualified calls cannot be rerouted to Rewired because the compiler is explicitly instructed which Input class to use.

Now I tried looking at Cinemachine's free look cam code just to see if it was using Input.GetAxis and it wasn't. It assigned the Axis using different input code to access Unity's Input system.

Now i'm no programmer so I wouldn't know how to make custom actions for these two plugins. I do hope that Guavaman sees this and make a Get Axis Vector action
 and Cinemachine Set Freelook cam Axis action that's compatible with ReWired. Those actions are literally the bread and butter to any 3rd person game and non coders would greatly benefit from it for sure.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #1 on: July 30, 2018, 01:00:58 AM »
I won't be making an Action to replicate what GetAxisVector does. Rewired provides input. It does not provide in interpretation/use of that input. IE: transforming input into other spaces, moving objects, etc. That is beyond the scope of the system. It would quickly snowball into a gigantic monster with an infinite number of expected actions/methods for every different use case everyone has.

The proper way to do something like this is to separate the "getting the input value" and "transforming the input value" into two separate actions. Then you simply get the input, store it in a variable, then transform the input and apply it to whatever you want to apply it to.

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #2 on: July 30, 2018, 01:20:15 AM »
I won't be making an Action to replicate what GetAxisVector does. Rewired provides input. It does not provide in interpretation/use of that input. IE: transforming input into other spaces, moving objects, etc. That is beyond the scope of the system. It would quickly snowball into a gigantic monster with an infinite number of expected actions/methods for every different use case everyone has.

The proper way to do something like this is to separate the "getting the input value" and "transforming the input value" into two separate actions. Then you simply get the input, store it in a variable, then transform the input and apply it to whatever you want to apply it to.

Thanks Guavaman,

How about Cinemachine Free look Cam? Any tips on how I could override Input controllers there with the current actions provided or would that require some custom code?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14400
  • Official Playmaker Support
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #3 on: July 30, 2018, 02:58:54 AM »

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #4 on: July 30, 2018, 09:31:38 AM »
I also cannot get the proper usage of Get Axis Vector for movement relative to camera position.

This is a simple and very common transformation operation:

Code: [Select]
// Transform from camera space to world space
Vector3 worldSpaceMoveVector = Camera.main.transform.TransformDirection(inputVector);

// Apply deltaTime and speed
worldSpaceMoveVector *= Time.deltaTime * speed;

// Move the object in world space
target.Translate(worldSpaceMoveVector, Space.World);

You should be able to easily do the same using PlayMaker actions.
« Last Edit: July 30, 2018, 04:31:39 PM by Guavaman »

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #5 on: July 30, 2018, 09:59:56 AM »
I won't be making an Action to replicate what GetAxisVector does. Rewired provides input. It does not provide in interpretation/use of that input. IE: transforming input into other spaces, moving objects, etc. That is beyond the scope of the system. It would quickly snowball into a gigantic monster with an infinite number of expected actions/methods for every different use case everyone has.

The proper way to do something like this is to separate the "getting the input value" and "transforming the input value" into two separate actions. Then you simply get the input, store it in a variable, then transform the input and apply it to whatever you want to apply it to.

Thanks Guavaman,

How about Cinemachine Free look Cam? Any tips on how I could override Input controllers there with the current actions provided or would that require some custom code?

Jean's post shows what you need. Here's a more simplified version:

(code removed)
« Last Edit: July 30, 2018, 09:09:34 PM by Guavaman »

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #6 on: July 30, 2018, 03:34:40 PM »
Thank you so much you guys are literally the best. I'll save this cinemachine script forever! having control of the free look cam was the deciding factor of weither i'll be using ReWired or unity's dreadful input system.
« Last Edit: July 30, 2018, 03:38:02 PM by mrminico »

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #7 on: July 30, 2018, 04:30:28 PM »
Thank you so much you guys are literally the best. I'll save this cinemachine script forever! having control of the free look cam was the deciding factor of weither i'll be using ReWired or unity's dreadful input system.

I posted two versions (somewhat modified) here:
https://forum.unity.com/threads/making-cinemachine-play-nice-with-rewired.517547/#post-3580596

One is a MonoBehaviour version and the other is a static version. Both can have their player ids changed, just with a different method. There will also links to download these in the documentation starting with the next version.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #8 on: July 30, 2018, 08:40:19 PM »
I updated the script with a new unified version:
https://forum.unity.com/threads/making-cinemachine-play-nice-with-rewired.517547/#post-3580596

It also works better with joystick/keyboard input.

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #9 on: July 31, 2018, 02:27:28 PM »
I updated the script with a new unified version:
https://forum.unity.com/threads/making-cinemachine-play-nice-with-rewired.517547/#post-3580596

It also works better with joystick/keyboard input.


Thanks! This is awesome for ReWired! Can't wait to see it up officially on the site's documentation. I'm super excited about this. As soon as I get home I'll copy the code from the forums and give it a spin.

Also, what would you recommend not to do when using ReWired that can impact performance. I know every plugin works Unity differently and I always like to ask the developers directly since they know best.
« Last Edit: July 31, 2018, 02:33:39 PM by mrminico »

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #10 on: July 31, 2018, 03:35:06 PM »
I updated the script with a new unified version:
https://forum.unity.com/threads/making-cinemachine-play-nice-with-rewired.517547/#post-3580596

It also works better with joystick/keyboard input.


Thanks! This is awesome for ReWired! Can't wait to see it up officially on the site's documentation. I'm super excited about this. As soon as I get home I'll copy the code from the forums and give it a spin.

Also, what would you recommend not to do when using ReWired that can impact performance. I know every plugin works Unity differently and I always like to ask the developers directly since they know best.

I just changed it. Now it's included as a menu install just like every other integration.

Optimization:
http://guavaman.com/projects/rewired/docs/HowTos.html#optimization

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #11 on: August 03, 2018, 02:48:43 PM »
I updated the script with a new unified version:
https://forum.unity.com/threads/making-cinemachine-play-nice-with-rewired.517547/#post-3580596

It also works better with joystick/keyboard input.


Thanks! This is awesome for ReWired! Can't wait to see it up officially on the site's documentation. I'm super excited about this. As soon as I get home I'll copy the code from the forums and give it a spin.

Also, what would you recommend not to do when using ReWired that can impact performance. I know every plugin works Unity differently and I always like to ask the developers directly since they know best.

I just changed it. Now it's included as a menu install just like every other integration.

Optimization:
http://guavaman.com/projects/rewired/docs/HowTos.html#optimization

Hey Guavaman I just got around to opening up unity under what menu is the Cinemachine script located? I see everything else but that under Window>ReWired I checked under extras and integration and didn't see anything Cinemachine related.

Guavaman

  • Playmaker Newbie
  • *
  • Posts: 38
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #12 on: August 03, 2018, 04:32:44 PM »
I just uploaded the update yesterday. The Unity Asset store has not published it yet. 1.1.19.0.

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #13 on: August 03, 2018, 09:29:15 PM »
I just uploaded the update yesterday. The Unity Asset store has not published it yet. 1.1.19.0.

Got it as soon as it rolls out i'll definitely check it out and let you know if everything worked fine. Thanks for making this possible Guavaman!

mrminico

  • Junior Playmaker
  • **
  • Posts: 76
    • View Profile
Re: Rewired/Cinemachine Actions discussion
« Reply #14 on: August 08, 2018, 03:19:43 AM »
I just uploaded the update yesterday. The Unity Asset store has not published it yet. 1.1.19.0.

Hey Guavaman,

I got around to getting the update everything worked! 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 :/

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

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?
« Last Edit: August 08, 2018, 04:55:51 AM by mrminico »