- Home /
Need some help with a platformer player script
I'm trying to learn to make a 3D platformer using a book I got, and so far I've followed it to make a functioning player control script, but it seems like it doesn't teach me some other things I'd like to do.
I'd like the player character to face the same direction they're moving in instead of only being able to face forward. And then once they stop moving I'd like them to still face the direction they were last moving in.
I'd like to edit the dash so upon first pressing the key you dash a set distance without having to hold down the key, so you can just press the key to do a dash move but you can also hold the key down to keep dashing.
I need the player to not be able to double jump in the air. The book I read had a part on this which I tried following in my script, but the character can still jump a little bit in the air, like it's a small jump like there's gravity weighing them down but it still needs to be fixed so you can jump again at all in the air.
I hope my words are easy to understand, I have trouble describing technical things.
{
public float Speed = 5f;
public float Dash = 7f;
public float Jump = 20f;
public bool gc = false;
public bool GroundTouch = false;
public Text countText;
public Text winText;
private int count;
private int SetCountText;
float DashDistance = 2;
// Start is called before the first frame update
void Start()
{
{
gc = true;
count = 0;
}
}
private void FixedUpdate()
{
if (Input.GetKey(KeyCode.W))
{
transform.position += Vector3.forward * Time.deltaTime * Speed;
}
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left * Time.deltaTime * Speed;
}
if (Input.GetKey(KeyCode.S))
{
transform.position += Vector3.back * Time.deltaTime * Speed;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right * Time.deltaTime * Speed;
}
if (Input.GetKey(KeyCode.Space))
{
transform.position += Vector3.up * Time.deltaTime * Jump;
}
if (Input.GetKey(KeyCode.W) && (Input.GetKey(KeyCode.LeftShift)))
{
transform.position += Vector3.forward * Time.deltaTime * Dash;
}
if (Input.GetKey(KeyCode.A) && (Input.GetKey(KeyCode.LeftShift)))
{
transform.position += Vector3.left * Time.deltaTime * Dash;
}
if (Input.GetKey(KeyCode.S) && (Input.GetKey(KeyCode.LeftShift)))
{
transform.position += Vector3.back * Time.deltaTime * Dash;
}
if (Input.GetKey(KeyCode.D) && (Input.GetKey(KeyCode.LeftShift)))
{
transform.position += Vector3.right * Time.deltaTime * Dash;
}
Vector3 gc = transform.TransformDirection(Vector3.down);
if (Physics.Raycast (transform.position, gc, .5f))
{
GroundTouch = true;
}
Your answer

Follow this Question
Related Questions
Need to restrict "air control" 2D platformer. 1 Answer
Bullet Script Problem 2 Answers
how d you change PlatformEffector2D rotationaloffset change as prefabs in android? 0 Answers
Need help accessing booleans from other script. 2 Answers
How to make a companion that trails character moves, and not collide? 0 Answers