using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Character : MonoBehaviour
{
Rigidbody rb;
float speed;
void Start()
{
rb = GetComponent();
speed = 10.0f;
}
void Update()
{
if (Input.GetKey(KeyCode.RightArrow))
{
rb.velocity = new Vector3(rb.velocity.x + 0.03f, rb.velocity.y, rb.velocity.z);;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
rb.velocity = new Vector3(rb.velocity.x - 0.03f, rb.velocity.y, rb.velocity.z);;
}
}
}![alt text][1]
[1]: /storage/temp/202642-screenshot-2022-11-27-171837.png
↧