I need to port my pc game to android.
I’m trying a code like this but its not working
(CrossPlatformInputManager.GetButtonDown ("E")) = (Input.GetKeyDown (KeyCode.E));
please help me
I need to port my pc game to android.
I’m trying a code like this but its not working
(CrossPlatformInputManager.GetButtonDown ("E")) = (Input.GetKeyDown (KeyCode.E));
please help me
if (CrossPlatformInputManager.GetButtonDown ("E")) {
Input.GetKeyDown (KeyCode.E);
}
also it didnt work
If you want to know whether you’re getting “E” from either of two different input systems, you’d write something like
if (CrossPlatformInputManager.GetButtonDown("E") || Input.GetKeyDown(KeyCode.E))
{
// Do stuff
}
actually I want to do this = when I press a button, it must act like I press E key
Well, you certainly can’t do that in anything like the way you’re trying to do it (and probably not at all). Those aren’t variables, they’re functions; when you invoke one, it runs some code and returns an answer. You can’t “set” their values (at least not directly).
I haven’t used CrossPlatformInputManager and it’s not showing up in the Unity scripting API, so I’m not sure what it’s capabilities are, but UnityEngine.Input doesn’t have a way for you to override its values. CrossPlatformInputManager kinda sounds like it should probably already handle input from multiple platforms without you needing to do anything, so if you haven’t already, you should definitely look into how that works and see if it already does everything you need by itself.
But if you need to combine them–and if neither of their creators did a bunch of extra work specifically to allow you to do that–then you’ll need to do it by changing how your code reacts to them, not by changing the inputs themselves. You can either go to every place that your code is testing one of them and make it also test the other, or you can write your own middle layer that combines both of them into one thing and then make all of your code go through your middle layer instead of talking to them directly.
But changing one to match the other is probably not in the cards.
I understand thank you my friend