36 lines
817 B
C#
36 lines
817 B
C#
using UnityEngine;
|
|
|
|
public class DropletMovement : MonoBehaviour
|
|
{
|
|
private Rigidbody2D rb;
|
|
public float moveSpeed = 5f;
|
|
public float jumpingPower = 5f;
|
|
private Vector2 movement;
|
|
private Animator playerAnim; //for animation
|
|
private float xInput;
|
|
|
|
public float moveSpeed = 5f;
|
|
public float jumpingPower = 5f;
|
|
|
|
private Vector2 movement;
|
|
|
|
void Start()
|
|
{
|
|
rb = GetComponent<Rigidbody2D>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
movement.x = Input.GetAxisRaw("Horizontal");
|
|
|
|
if (isGrounded && Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpingPower);
|
|
}
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
|
|
}
|
|
} |