Last active
May 1, 2022 11:08
-
-
Save daichi-takezawa/da59fbe0511439fced8181ec2ce14516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3 movingDirecion; | |
public float speedMagnification; //調整必要 例10 | |
public RigidBody rb; | |
public Vector3 movingVelocity; | |
void Start(){ | |
rb = Getcomponent<RigidBody>(); | |
} | |
void Update() { | |
float x = Input.GetAxisRaw("Horizontal"); | |
float z = Input.GetAxisRaw("Vertical"); | |
movingDirecion = new Vector3(x, 0, z); | |
movingDirecion.Normalize();//斜めの距離が長くなるのを防ぎます | |
movingVelocity = movingDirecion * speedMagnification; | |
} | |
void FixedUpdate() { | |
if (jumpNow == true) return; | |
rb.velocity = new Vector3(movingVelocity.x, rb.velocity.y, movingVelocity.z); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment