Hey guys, i am trying to make the player fly, but i can’t make it work! I am using the Standard First Person Character, and i am trying to make him be able to fly when he enter the water so he will not be traped or something. The problem i am having is that he just doesn’t fly. If i add my script to a cube or anything else, when i press space i can make them fly, but not my character! I tried removing it’s scripts but still it doesn’t go. Someone know why? Can you help me?
This is my script, you can test it if you want:
using UnityEngine;
using System.Collections;
public class Fly : MonoBehaviour
{
bool JumpPressed = false;
public float jumpAccelleration = 3;
void Update()
{
if (!JumpPressed)
JumpPressed = Input.GetKey(KeyCode.Space);
}
void FixedUpdate()
{
if (JumpPressed) GetComponent<Rigidbody>().AddForce(new Vector3(0, jumpAccelleration, 0), ForceMode.Impulse);
if (JumpPressed) JumpPressed = false;
}
}