Hi,
I’m working on making a character controlled by a Bluetooth iCade controller (and relatively new to coding). They move, however I can’t seem to get the gravity aspect to work… When they should fall, they keep on walking in the air. This script is attached to a simple character. Here’s the code:
using UnityEngine;
using System.Collections;
public class ControllerInput : MonoBehaviour
{
** public float gravity = 10F;**
** private Vector3 moveDirection = Vector3.zero;**
void Start ()
{
iCadeBinding.setActive( true );
}
void Update ()
{
iCadeBinding.updateState();
Control();
}
void Control()
{
if (iCadeBinding.state.JoystickUp)
{
transform.position += Vector3.forward * 1 * Time.deltaTime;
}
else if (iCadeBinding.state.JoystickDown)
{
transform.position += Vector3.forward * -1 * Time.deltaTime;
}
if (iCadeBinding.state.JoystickLeft)
{
transform.position += Vector3.right * -1 * Time.deltaTime;
}
else if (iCadeBinding.state.JoystickRight)
{
transform.position += Vector3.right * 1 * Time.deltaTime;
}
__ moveDirection.y -= gravity * Time.deltaTime;__
}
}
Any recommendations on how to make this work? Thanks for your help!