game objects leaving trail of it's self
so I'm doing the space shooter tutorial make the changes need to get the player to move.
using UnityEngine; using System.Collections;
[System.Serializable] public class Boundary { public float xMin, xMax, zMin, zMax; }
public class PlayerController : MonoBehaviour { public float speed; public float tilt; public Boundary boundary; private Rigidbody rb; void Start() { rb = GetComponent(); }
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
//rb.velocity = movement * speed;
rb.AddForce(movement * speed);
rb.position = new Vector3
(
Mathf.Clamp(rb.position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)
);
rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
}
} I change the //rb.velocity = movement speed; for rb.AddForce(movement speed); because velocity only moved it like a fraction of a inch and not move any further expect to origin. so I'm alittle confused on what to try.
Your answer
Follow this Question
Related Questions
[Solved] I am trying to build a space sim/ shooter type game. 1 Answer
Trail effect for non-moving object 2 Answers
Problem with fireing multiple raycasts at once 0 Answers
Project Space Shooter: My ship won't move! 2 Answers
Space Battle AI issues 0 Answers