使用unity store寻找素材,编辑素材,并且用c#为我的人物添加了简单的移动动作,为场景和人物添加刚体,使其具有重力。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playcontroller : MonoBehaviour
{
public Rigidbody2D rb;
public float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Movement();
}
void Movement()
{
float horizontalmove;
horizontalmove=Input.GetAxis("Horizontal");
if(horizontalmove!=0)
{
rb.velocity = new Vector2(horizontalmove * speed, rb.velocity.y);
}
}
}
标签:frame,void,public,horizontalmove,unity,rb,using,study From: https://blog.51cto.com/u_15918782/6091825