making an rpg character on android

Alright, so I want to make an rpg style character on a touchscreen. Here are some key things I want to do:

  1. I want the camera view to be 1st-person.
  2. I want the x-axis of the camera to only rotate 60 or so degrees (basically you cant look straight up or down).
  3. I want a joystick on the left to control movement.
  4. I want the entire right side of the screen to be a “look” joystick, so that you can touch anywhere on right side of screen to look around.
  5. Keep in mind that this is on android so it will have to be compatible with many screen sizes. So 2DTexture joysticks are out of the question, because it might look right on a tablet, but then on a phone screen the joystick is like 400 pixels off the screen…

So how do I do this? The standard assests has character controllers for everything but this it seems, and I have NO IDEA where to start… I had a (kind of working) character which was actually a 3rd person controller with the camera inside the character like a 1st person. I hade two joysticks on either side of the screen. I wasn’t able to get #2 or 4 on my list to work with this system though, so now I have come to the forums for help. Any ideas?

You can start here:

They cover some of the stuff you’re after. For RPG mechanics, you’re up for a struggle, believe me. I’m not the guy to advise you on that. Anyway, start with something simpler, man. Really.

Hugo is right, if you dont have any experience you should start smaller or invest in a rpg kit like ORK framework or PlyGame and even then you should have an idea with unity on setting things up, you just dont create RPG’s Kit or no kit and since your going mobile you need to further know your limits packing an RPG into a mobile game…its been done many times over but im assuming they have the know how/tricks to make it work…just some advice

Well I have been learning unity for a year now and am actually very fluent in java script. I have made a strategy game that turned out relatively good. I am also (somewhat) experienced with android. I don’t really need you guys to write a whole script for me, which I think is what you guys were thinking; I just need someone to point me in the right direction on most of these. For instance, is there another way to make joysticks without 2d textures that I am missing?

Just stuff like that, I don’t really need all the questions answered but a few hints and tips on how to do this from other peoples’ experience would be nice. Sorry if my topic wasn’t very clear /:

  1. Set up clamps for the ability to move. Check out Mathf.clamp. You should be able to go from there. You’re going to only want to clamp the camera’s Y coordinate, as you still want to rotate 360.

3&4: Joystick tutorial:

Note: This is a c# script, and i’m not sure if it works with java.

5: To keep things in position use this awesome script by http://pixelplacement.com/ (sorry I can’t link directly, their website is acting funky right now, full credit to them)

To use:
transform.ScreenPlacement(ScreenPosition.LowerLeft, new Vector2(60,55));
This will move the object the script is located on to the camera’s lower left anchor, with an X from the edge of 60, and a Y from the edge of 55.

Add this to your project in a separate script:

using UnityEngine;

/// <summary>
/// Screen positions for use with the ScreenPlacement transform and gameObject extension for the 9 positions around the screen edge.
/// </summary>
public enum ScreenPosition {UpperLeft, UpperMiddle, UpperRight, Left, Middle, Right, LowerLeft, LowerMiddle, LowerRight};

public static class ScreenPlacementExtension{

    //Add instructions

    //GameObject overrides:
    /// <summary>
    /// Places a GameObject at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="GameObject"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    public static void ScreenPlacement(this GameObject target, ScreenPosition position){
        DoScreenPlacement(target.transform, position, Vector2.zero, Camera.main);
    }

    /// <summary>
    /// Places a GameObject at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="GameObject"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="renderingCamera">
    /// A <see cref="Camera"/>
    /// </param>
    public static void ScreenPlacement(this GameObject target, ScreenPosition position, Camera renderingCamera){
        DoScreenPlacement(target.transform, position, Vector2.zero, renderingCamera);
    }

    /// <summary>
    /// Places a GameObject at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="GameObject"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="pixelsFromEdge">
    /// A <see cref="Vector2"/>
    /// </param>
    public static void ScreenPlacement(this GameObject target, ScreenPosition position, Vector2 pixelsFromEdge){
        DoScreenPlacement(target.transform, position, pixelsFromEdge, Camera.main);
    }

    /// <summary>
    /// Places a GameObject at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="GameObject"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="pixelsFromEdge">
    /// A <see cref="Vector2"/>
    /// </param>
    /// <param name="renderingCamera">
    /// A <see cref="Camera"/>
    /// </param>
    public static void ScreenPlacement(this GameObject target, ScreenPosition position, Vector2 pixelsFromEdge, Camera renderingCamera){
        DoScreenPlacement(target.transform, position, pixelsFromEdge, renderingCamera);
    }

    //Transform overrides:

    /// <summary>
    /// Places a Transform at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="Transform"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    public static void ScreenPlacement(this Transform target, ScreenPosition position){
        DoScreenPlacement(target.transform, position, Vector2.zero, Camera.main);
    }

    /// <summary>
    /// Places a Transform at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="Transform"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="renderingCamera">
    /// A <see cref="Camera"/>
    /// </param>
    public static void ScreenPlacement(this Transform target, ScreenPosition position, Camera renderingCamera){
        DoScreenPlacement(target.transform, position, Vector2.zero, renderingCamera);
    }

    /// <summary>
    /// Places a Transform at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="Transform"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="pixelsFromEdge">
    /// A <see cref="Vector2"/>
    /// </param>
    public static void ScreenPlacement(this Transform target, ScreenPosition position, Vector2 pixelsFromEdge){
        DoScreenPlacement(target.transform, position, pixelsFromEdge, Camera.main);
    }

    /// <summary>
    /// Places a Transform at one of the 9 positions around the screen edge.
    /// </summary>
    /// <param name="target">
    /// A <see cref="Transform"/>
    /// </param>
    /// <param name="position">
    /// A <see cref="ScreenPosition"/>
    /// </param>
    /// <param name="pixelsFromEdge">
    /// A <see cref="Vector2"/>
    /// </param>
    /// <param name="renderingCamera">
    /// A <see cref="Camera"/>
    /// </param>
    public static void ScreenPlacement(this Transform target, ScreenPosition position, Vector2 pixelsFromEdge, Camera renderingCamera){
        DoScreenPlacement(target.transform, position, pixelsFromEdge, renderingCamera);
    }

    //Placement execution:
    private static void DoScreenPlacement(this Transform target, ScreenPosition position, Vector2 pixelsFromEdge, Camera renderingCamera){
        Vector3 screenPosition = Vector3.zero;
        float zPosition =  -renderingCamera.transform.position.z + target.position.z;
   
        switch (position) {   
   
        //uppers:
        case ScreenPosition.UpperLeft:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(pixelsFromEdge.x, Screen.height-pixelsFromEdge.y, zPosition));
        break;
       
        case ScreenPosition.UpperMiddle:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3( (Screen.width/2)+pixelsFromEdge.x, Screen.height-pixelsFromEdge.y, zPosition));
        break;
       
        case ScreenPosition.UpperRight:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(Screen.width-pixelsFromEdge.x, Screen.height-pixelsFromEdge.y, zPosition));
        break;
   
        //mids:
        case ScreenPosition.Left:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(pixelsFromEdge.x, (Screen.height/2) - pixelsFromEdge.y, zPosition));
        break;
           
        case ScreenPosition.Middle:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3((Screen.width/2) + pixelsFromEdge.x, (Screen.height/2) - pixelsFromEdge.y, zPosition));
        break;
       
        case ScreenPosition.Right:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(Screen.width-pixelsFromEdge.x, (Screen.height/2)-pixelsFromEdge.y, zPosition));
        break;
   
        //lowers:
        case ScreenPosition.LowerLeft:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(pixelsFromEdge.x, pixelsFromEdge.y, zPosition));
        break;
       
        case ScreenPosition.LowerMiddle:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3((Screen.width/2)+pixelsFromEdge.x, pixelsFromEdge.y, zPosition));
        break;
       
        case ScreenPosition.LowerRight:
            screenPosition = renderingCamera.ScreenToWorldPoint(new Vector3(Screen.width-pixelsFromEdge.x, pixelsFromEdge.y, zPosition));
        break;       
       
       
        }
   
        target.transform.position = screenPosition;
    }
}

I also found another reference to the ScreePosition script here:
http://www.1678zz.com/projects/rear-pro/repository/revisions/c09d86106b4f4cc773b5221235a876f066fd78d7/show/Assets/Extensions/StansAssetsPreviewUI/Scripts/ScreenPlacementExtension

awesome using mathf camp worked. And I found a way to make 2D textures stay the same size relative to the screen size. Also i watched a tutorial on touchpads so #4 is answered. Thanks for the help I can take it from here, wish me luck though :stuck_out_tongue:

Oh coders always wish other coders luck :slight_smile:
Mr Burns Hand Pyramid