Search Unity

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

Discussion in 'Community Learning & Teaching' started by Devin-Curry, Jan 18, 2015.

  1. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    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
     
    Last edited: Jan 16, 2016
    John3D, softwizz and kurukshetran like this.
  2. softwizz

    softwizz

    Joined:
    Mar 12, 2011
    Posts:
    793
    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.
     
    Devin-Curry likes this.
  3. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    Thanks Softwizz :) 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.

     
  4. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    Finally got around to publishing the updated mobile FPS control using Canvas UI :D

     
    softwizz likes this.
  5. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    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
     
  6. Megadime

    Megadime

    Joined:
    Oct 28, 2013
    Posts:
    1
    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}
     
  7. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    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<Rigidbody2D>();" I've updated my website to fix that
     
  8. softwizz

    softwizz

    Joined:
    Mar 12, 2011
    Posts:
    793
    Just thought I would come back and say thanks for the update, excellent tutorial.
     
  9. karlserra

    karlserra

    Joined:
    Sep 1, 2015
    Posts:
    6
    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.InvokableCall`1[System.Single].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:168)
    UnityEngine.Events.CachedInvokableCall`1[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.UnityEvent`1[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.EventFunction`1 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
     
  10. Devin-Curry

    Devin-Curry

    Joined:
    Sep 30, 2013
    Posts:
    22
    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


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

    Part 5b - Enemy Death


    The script for part 5b can be found on this page of my website
     
    Last edited: Apr 28, 2016