Need explaination of a game

Hi guyzzz i come frm an unreal engine and source engine background…

Theres a game named missiles in android …
Made in unity 3d…

I jst wanna know 2 things of this game

  1. Is this game using an infinite scrolling background

  2. How to implement tht plane controls(is it rotation or movement)

Here the link to the game:

https://www.google.co.in/url?sa=t&source=web&rct=j&url=https://play.google.com/store/apps/details%3Fid%3Dpl.macaque.Missiles%26hl%3Den%26referrer%3Dutm_source%253Dgoogle%2526utm_medium%253Dorganic%2526utm_term%253Dmissiles%2Bandroid%2Bgame%2Bl%26pcampaignid%3DAPPU_1_Jdd4WI-GKsHhvgS28rN4&ved=0ahUKEwjPrIuHnr_RAhXBsI8KHTb5DA8Q5YQBCBkwAA&usg=AFQjCNGIGnebQFPvCXLKCY7ieAYfXXOJ8Q

The background looks like a solid color, that could be the Camera’s background color. The clouds could be a particle system or simple spawning script. Without playing it, I would guess that the planes are always moving along the object’s local forward axis, and rotating to steer.

hmm thanks a lot…

can u also tell how to do tht rotation thing on a virtual joystick???

With the virtual joystick added, it should give you input values between -1 and 1 for the horizontal axis of the joystick. You can use that, multiplied by delta time and an angle-per-second to rotate, and do a transform.Rotate() around the Z axis, or “Vector3.forward”.

If you want the ship to rotate to the direction the joystick is facing, use both the horizontal and the vertical axes of the joystick as a Vector2 direction. Then you could do “transform.right = (vector2 from joystick)”

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class JoystickControllerSystem : MonoBehaviour , IDragHandler , IPointerUpHandler , IPointerDownHandler
{

private Image BgImg;
private Image JoystickImg;
public Vector3 inputVector;
public Vector3 _moveVector;

void Update()
{
Debug.Log (inputVector);
}

void Start()
{
BgImg = GetComponent ();
JoystickImg = transform.GetChild (0).GetComponent ();
}

public virtual void OnDrag (PointerEventData ped)
{
Vector2 pos;
if(RectTransformUtility.ScreenPointToLocalPointInRectangle(BgImg.rectTransform ,
ped.position , ped.pressEventCamera , out pos))
{
pos.x = (pos.x / BgImg.rectTransform.sizeDelta.x);
pos.y = (pos.y / BgImg.rectTransform.sizeDelta.y);

inputVector = new Vector3 (pos.x* 2 + 1, 0, pos.y * 2 - 1);
inputVector = (inputVector.magnitude > 1.0f) ? inputVector.normalized : inputVector;

_moveVector = new Vector3 (pos.x* 2 + 1, 0, pos.y * 2 - 1);
_moveVector = (_moveVector.magnitude > 1.0f) ? _moveVector.normalized : _moveVector;

JoystickImg.rectTransform.anchoredPosition = new Vector3 (inputVector.x * (BgImg.rectTransform.sizeDelta.x / 2),
inputVector.z * (BgImg.rectTransform.sizeDelta.y / 2));
}
}

public virtual void OnPointerUp (PointerEventData ped)
{
inputVector = Vector3.zero;
JoystickImg.rectTransform.anchoredPosition = Vector3.zero;
}

public virtual void OnPointerDown (PointerEventData ped)
{
OnDrag (ped);
}

}

I have The Above as my Virtual Joystick…

but iam still not getting the rotation part wich u said(the angle-per-second?)

Please use Code Tags when pasting code into the forums, it will preserve formatting and give it line numbers etc.

From the looks of it, you will be using “inputVector” for the rotation. So for your ship rotation, you’ll need to get access to the “inputVector” of the joystick in the script that controls the ship movement. Something like this:

private void Update(){
    float angleToRotate = inputVector.x * anglePerSecond * Time.deltaTime;

    transform.Rotate(Vector3.forward, angleToRotate);
}

Hmm Thanks for the suggestion…(Code Tags One) Ill keep in mind…

wht should be the “anglepersecond” be??

Try different values and see what feels good. Maybe somewhere between 1 and 10.

But The plane doesnt rotate whn i use the joystick in Z direction…

also it is not stopping at the point whr i hold the joystick…it jst keeps rotating…

Any particular reason you’re using Z as the up axis? In Unity the 2D plane is Y up.

That is the other of the two options I described before. One just keeps rotating as you hold left or right. The other uses the direction of the joystick as the direction to point the ship.

Something like this should do it:

Vector3 direction = new Vector3(inputVector3.x, inputVector.z, 0);
transform.right = Vector3.MoveTowards(transform.right, direction, rotationSpeed * Time.deltaTime);

If the ship faces down the Y axis, use transform.up instead.

But how to Stop The rotation at the point whr the plane has rotated to the joystick location

That is why my code sample should do. It moves the X axis of the ship towards the joystick direction. Once it’s there it will stop.

This is my plane Script…jst tell me wht to add more…

using UnityEngine;
using System.Collections;

public class RotatePlane : MonoBehaviour
{
    public float anglePerSecond = 20;
    public JoystickControllerSystem jYSystem;

    void Update()
    {


        if (jYSystem._moveVector == Vector3.zero) {
           
        } else {

            float angleToRotate = -jYSystem.inputVector.x * anglePerSecond * Time.deltaTime;
            transform.Rotate (Vector3.forward, angleToRotate);
            //Vector3 dir = new Vector3(jYSystem.inputVector.x , jYSystem.inputVector.y , 0);
            //transform.up = Vector3.MoveTowards (transform.up, dir, 5 * Time.deltaTime);
        }

    }
}

Try this

using UnityEngine;
using System.Collections;

public class RotatePlane : MonoBehaviour
{
    public float anglePerSecond = 20;
    public JoystickControllerSystem jYSystem;

    void Update()
    {


        if (jYSystem._moveVector == Vector3.zero) {
          
        } else {
            Vector3 dir = new Vector3(jYSystem.inputVector.x , jYSystem.inputVector.z , 0);
            transform.up = Vector3.MoveTowards (transform.up, dir, 5 * Time.deltaTime);
        }

    }
}

Yeah… It worked Thanks A Lot a Dude… For Helping…
;):):slight_smile:

1 Like