using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class moving : MonoBehaviour
{
public Rigidbody2D rigid2D;
// 新增控制角色的剛體的動作
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space"))
{
rigid2D.AddForce(new Vector2(0, 20),ForceMode2D.Impulse);
print("jump");
}
if (Input.GetKey("left"))
{
transform.Translate(-0.05f, 0, 0);
}
if (Input.GetKey("right"))
{
transform.Translate(0.05f, 0, 0);
}
if (Input.GetKey("down"))
{
transform.Translate(0, -0.05f, 0);
}
}
}
rigid2D.AddForce(new Vector2(0, 20),ForceMode2D.Impulse);print("jump");
https://www.youtube.com/c/RemptyGame