Skip to content

Instantly share code, notes, and snippets.

@EdSkamor
Last active September 15, 2017 07:06
Show Gist options
  • Save EdSkamor/e2f596902fd799a1e7523b725719cc16 to your computer and use it in GitHub Desktop.
Save EdSkamor/e2f596902fd799a1e7523b725719cc16 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class chaCon : MonoBehaviour {
private Rigidbody m_rb;
[SerializeField] float m_speed = 10f;
void Start () {
m_rb = GetComponent<Rigidbody>();
}
void Update () {
float x = CrossPlatformInputManager.GetAxis("Horizontal");
float z = CrossPlatformInputManager.GetAxis("Vertical");
Vector3 movement = new Vector3(x, 0f, z);
m_rb.AddForce(movement * m_speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment