0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float Speed;
public float JumpForce;
private Rigidbody2D rig;
// Use this for in
itialization
void Start () {
rig = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
Move();
Jump();
}
void Move () {
Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
transform.position += movement * Time.deltaTime * Speed;
}
void Jump () {
if(Input.GetButtonDown("Jump")) {
rig.AddForce(new Vector2(0f, JumpForce), ForceMode2D.Impulse);
}
}
}