#Modify 2d movement script for android

1 messages · Page 1 of 1 (latest)

tidal mortar
#

hi can anyone guide me how can i modify this 2D MOVEMENT script for to move and jump my player with buttons in unity

leaden depotBOT
#

Use codeblocks to send code in a message!

To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.

For example:
```cs
Console.WriteLine("Hello World");
```

Produces:

Console.WriteLine("Hello World");

To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.

wanton flower
#

In general, you would typically use public functions to do the specific logic you want such as jumping, then the script doesnt need to poll input in Update, or even know about any input at all, since functions can take params - your UI buttons or keyboard input or game triggers or however you want to interact with your code, can then call those public functions - you could also setup events on your input/buttons/triggers/etc, and have your player listen for those events by subscribing the relevant function to them, though with events, remember to always unsubscribe as well, typically OnEnable and OnDisable is used for that, but its not the only places events can be managed

tidal mortar
#

@wanton flower Thanks I will try it

tidal mortar
#

i am beginer cant understand that sorryFeelsCoffeeMan

wanton flower