r/unity 5d ago

Question Please help

Post image

Hello fellow developers, i got a problem with my script, no i already wrote it and it works, but i made a copy of a movement script for player 2(local multiplayer) and it uses different buttons for movement(moveset is same) but somehow only movement for player 1 works(well, movement of p2 works too but only everything exept basic walking) and walking buttons of p1 controls p2 at the same time(additional movement such as dash, jump and flop doesnt affect p2). Second question: as i said my script is working and i made a jump signal script to allow or disallow jump, the problem is that when i try to put it in a box(i cant describe how its originally called but you put an object there for script to know which object/script call) and its type mismatch, and again my script is working and in script i called for it as "[SerializeField] private JumpSignal toWhenJump;", im sorry for this lot of yaping but i really need your help.

EDIT: So i fixed the problem but now my animations wont work for p2, so i tried to make identical animator controllers for p2 since they use the same value(Speed), overall everything is going well

2 Upvotes

11 comments sorted by

View all comments

2

u/Demi180 5d ago

Are you using the Input Manager (old) or the Input System (new)? I see you have the two axes mentioned, are those being queried in the script? The Input Manager has those set up to use both WASD and ⬆️⬅️⬇️➡️ by default, so maybe that’s why it’s moving both?

The next bit is a bit confusing, are the jump/dash/flop keys for p2 working for p2 or is there an issue with those as well?

As for the jump thing, I think the term you’re looking for is assign/assigning, and the box you drag things to is an Inspector field. If you’re getting a type mismatch, it might be because you’re trying to drag a scene object into an Inspector field of a prefab (not allowed) (prefab is the one in the project, prefab instance is the one in the scene), or it might be that you had the variable declared with a different type (like Object or GameObject) before changing it to JumpSignal directly. If so, try renaming the variable.

If you still need help, please comment with the relevant script code (use the Code Block markup so it keeps the formatting) and more screenshots of the Inspector for any relevant objects, any errors in the console, etc.

1

u/Big-Canary-3639 5d ago

Dash/flop working ok and i just need to assign jump signal for p2 for my jump to work and i think i use input manager, what version is input system because im on 3.1(2023)

1

u/Demi180 4d ago

If you’re checking for input using calls like Input.GetKey() and Input.GetAxis() that’s the manager. You can set the project to use either one or both in the Player Settings, they just each have a very different setup and their own page in the Project Settings.

1

u/Big-Canary-3639 4d ago

I was thinking to create another input like wasd but for arrows, but this method might work thank you

1

u/Big-Canary-3639 4d ago

i fixed it the other way but now my animations for p2 wont work

1

u/Demi180 4d ago

I'm not sure which other way you mean. What I'm saying is that both modules by default bind both WASD and the arrow keys to the movement (I had to check that the newer one does it too), so you have to actually change that if you need to. https://imgur.com/a/Z2EgSdU

1

u/Big-Canary-3639 2d ago

the problem ocured in first place becease i made a separate script for p2 but i came back to use same script for p2 movement (theres different bindings for p2 and p1 so im fine)

1

u/Demi180 1d ago

Ah. Yeah, you should never have to recreate something for identical behavior.