Potrzebuje pomocy!
Przeszukałam wiele forum i innych i nie mogę zaprogramować skoku w moim krypcie postac moze latac a nie powinna wedlug moich zamyslow... Proszę o pomoc potrzebuje aby potać mogła płynnie skakać. Oto skrypt (chodzenie też tu jest)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float moveSpeed;
public float jumpHeight;
public Transform groundCheck;
public float groundCheckRadius;
public LayerMask WhatIsGround;
private bool grouned;
public bool DoubleJump;
public float speed = 3f;
private Rigidbody2D rgbody;
// Use this for initialization
void Start()
{
rgbody = GetComponent<Rigidbody2D>();
}
void FixedUpdate() {
grouned = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, WhatIsGround);
}
// Update is called once per frame
void Update()
{
if (grouned)
DoubleJump = false;
if (Input.GetKey(KeyCode.W))
{
rgbody.velocity = new Vector2(rgbody.velocity.x, speed);
}
if (Input.GetKey(KeyCode.D))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.GetKey(KeyCode.A))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}
}
}