- Home /
Question by
Denniard · Jan 14, 2018 at 03:39 PM ·
2d-platformertouch controlsladder
Mapping touch controls to ladder script
I'm using this script for my ladders but I need some help mapping it to touch controls.
using UnityEngine; using System.Collections;
public class Ladder : MonoBehaviour {
public float speed = 6f;
private bool onLadder;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerStay2D(Collider2D other)
{
if (other.tag == "Player" && Input.GetKey (KeyCode.W)) {
other.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, speed);
}
else if (other.tag == "Player" && Input.GetKey (KeyCode.S))
{
other.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, -speed);
}
else
{
other.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0,1);
}
}
}
Comment
Your answer
