0
0
Unityframework~10 mins

New Input System overview in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new InputAction.

Unity
var jumpAction = new InputAction(name: [1]);
Drag options to blanks, or click blank then click option'
A"Jump"
BJump
Cjump
DinputJump
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the action name.
Using a variable name without quotes.
2fill in blank
medium

Complete the code to enable the InputAction.

Unity
jumpAction.[1]();
Drag options to blanks, or click blank then click option'
AEnable
Brun
Cactivate
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Calling start() instead of enable().
Using activate() which does not exist.
3fill in blank
hard

Fix the error in the code to read the value of the InputAction as a float.

Unity
float value = jumpAction.ReadValue<[1]>();
Drag options to blanks, or click blank then click option'
Aint
Bbool
Cstring
Dfloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using int which is not suitable for analog input.
Using string or bool which are invalid types here.
4fill in blank
hard

Fill both blanks to create a dictionary of action names and their enabled status.

Unity
var actionStatus = actions.ToDictionary(action => [1], action => action.[2]);
Drag options to blanks, or click blank then click option'
Aaction.name
Benabled
CisEnabled
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using isEnabled or active which are not valid properties.
Using enabled without the action prefix.
5fill in blank
hard

Fill all three blanks to subscribe to the performed event with a callback method.

Unity
jumpAction.[1] += [2] => [3]();
Drag options to blanks, or click blank then click option'
Aperformed
Bcontext
COnJump
Dstarted
Attempts:
3 left
💡 Hint
Common Mistakes
Using started event instead of performed.
Not using a parameter in the lambda.
Calling a method name that does not exist.