[Tutorial] Making a 2d platformer with touch buttons for mobile

Hi all, I’m making a tutorial series on how to make a 2D side scrolling platformer game. These first 2 videos go over how to create the basic movement for keyboard, joystics, and on screen touch buttons for mobile using Unity 4.6 UI. I’ll be uploading the full series on my website, Devination.com, and you my YouTube channel. Please check out the videos if you’re interested and let me know what sort of stuff you’d like to see covered in future videos. Thanks!

Part 1 - Player Movement

Part 2 - Touch Input Buttons

The script for parts 1 and 2 can be found on this page of my website

Part 3 - Art and Animation

The scripts for part 3 can be found on this page of my website

Part 4 - Enemy Movement AI

The script for part 4 can be found on this page of my website

Part 5a - Player Damage and Death

The script for part 5a can be found on this page of my website

3 Likes

I found your youtube channel from a google search.
Please hurry up and get to remaking the mobile FPS control using 4.6

Thanks.

To anyone reading this Devin’s videos are very good.

1 Like

Thanks Softwizz :slight_smile: The 4.6 touch joystick/fps control is next on my todo list

In the mean time, here is part 3 of the platformer series. I show how to add animations to our 2d platformer character.

https://www.youtube.com/watch?v=YmywUBXTbWc

Finally got around to publishing the updated mobile FPS control using Canvas UI :smile:

https://www.youtube.com/watch?v=l7YiASYgDC0

1 Like

Just updated the top post with this but here’s Part 4! We make an enemy that moves forward on a platform until it hits a wall or an edge, then it turns around and moves the other direction forever.

Part 4 - Enemy Movement AI

The script for part 4 can be found on this page of my website

Hi! I have unity 5.1 and I used the script from your website. On script line “myBody = this.GetComponent<Rigidbody2D&gt();” I get {error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected}

Hi Megadime, the “&gt” is a bug from the HTML on my site. It’s supposed to be a “>” instead to make
“myBody =this.GetComponent();” I’ve updated my website to fix that

Just thought I would come back and say thanks for the update, excellent tutorial.

Error
NullReferenceException: Object reference not set to an instance of an object
PlayerController.FixedUpdate () (at Assets/PlayerController.cs:26)

NullReferenceException: Object reference not set to an instance of an object
PlayerController.StartMoving (Single horizonalInput) (at Assets/PlayerController.cs:53)
UnityEngine.Events.InvokableCall1[System.Single].Invoke (System.Object[ ] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:168) UnityEngine.Events.CachedInvokableCall1[System.Single].Invoke (System.Object[ ] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:286)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[ ] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:602)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[ ] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:744)
UnityEngine.Events.UnityEvent1[T0].Invoke (.T0 arg0) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_1.cs:53) UnityEngine.EventSystems.EventTrigger.Execute (EventTriggerType id, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/EventTrigger.cs:67) UnityEngine.EventSystems.EventTrigger.OnPointerDown (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/EventTrigger.cs:93) UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerDownHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:38) UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerDownHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
UnityEngine.EventSystems.EventSystem:Update()

in your code in animation can you help me

Looking at the line numbers in your error vs the line numbers on my website it’s a little difficult to match them up but I’m guessing it’s having trouble with either the isGrounded line or the myAnim line. Try using the debugger or making these variables (myTrans, tagGround, myAnim) public to make sure they actually hold references to the proper components. If they don’t it might be best to remove the code that’s meant to assign them in Start, leave them as public variables, and assign them in the Inspector.

Also here’s and update on the series: I just released part 5a - Player Death and Damage. I edited the first post to include this.

Part 5a - Player Damage and Death

https://www.youtube.com/watch?v=kRsBoo2p6uw

The script for part 5a can be found on this page of my website

Part 5b - Enemy Death

https://www.youtube.com/watch?v=e8DXLqGPosI

The script for part 5b can be found on this page of my website