私はUnity Gameプロジェクトに取り組んできました。私のスプライトは右に移動します。ここに私の現在のスクリプトは次のとおりです。ユニティオブジェクトの移動 - オブジェクトのみが右下に移動しますか?
#pragma strict
function Update(){
var ship = GetComponent(Rigidbody2D);
var speed = 10;
if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)){
ship.velocity.y = speed;
}else {
ship.velocity.y = 0;
}
if(Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)){
ship.velocity.x = -1 * speed;
}else {
ship.velocity.x = 0;
}
if(Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)){
ship.velocity.y = -1 * speed;
}else {
ship.velocity.y = 0;
}
if(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)){
ship.velocity.x = speed;
}else {
ship.velocity.x = 0;
}
}