i’m using the standard assets CrossPlatformInput and I can’t figure out how to write the script that allows my player to jump when a button is pressed - I and making an android mobile game so need to be able to touch the buton to make the character jump… Help please!
Here’s my character script…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Move : MonoBehaviour
{
private Rigidbody2D rb;
private float dirX, dirY, moveSpeed;
// Use this for initialization
void Start()
{
rb = GetComponent<Rigidbody2D>();
moveSpeed = 5f;
}
// Update is called once per frame
void Update()
{
dirX = CrossPlatformInputManager.GetAxis("Horizontal") * moveSpeed;
dirY = CrossPlatformInputManager.GetAxis("Vertical") * moveSpeed;
}
private void FixedUpdate()
{
rb.velocity = new Vector2(dirX, dirY);
}
void OnTriggerEnter2D(Collider2D triggerCollider)
{
}
}