what I have is a first person shooter. What I am shooting is arrows. When I shoot the arrow in one direction, it appears to be facing straight. when I am facing a different direction, it shoots it straight, but the arrow is facing sideways. This is very hard to explain lol. if I am facing one way it fires like a normal arrow, when i turn 90 degrees it shoot like this -----> but is going straight in front of me… I hope I explained this good. Thanks!
You are using world coordinates and not your arrow’s coordinates.
First we need to know what causes the arrow to shoot.
If it is by adding force, maybe you are using the
AddForce function. Look for it in your script and change it to AddRelativeForce.
var speed = 5.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis (“Horizontal”) * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis (“Vertical”);
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown(“Jump”))
{
var bullit = Instantiate(bullitPrefab, GameObject.Find(“spawnPoint”).transform.position, Quaternion.identity);
bullit.rigidbody.AddRelativeForce(transform.forward * 4000);
}
}
@script RequireComponent(CharacterController)
Heres the script that I am using…as you can see I did add the relative force. it didn’t change anything. Can someone please help me thanks!
hmmm… the problem is because of this line
var bullit = Instantiate(bullitPrefab, GameObject.Find(“spawnPoint”).transform.position, Quaternion.identity);
it says Quaternion.identity which means that the bullit
instantiated will have no rotation at all;
try replacing it with this.
var bullit = Instantiate(bullitPrefab, GameObject.Find(“spawnPoint”).transform.position, transform.rotation);
Nope I did the change and its still not working. Anyone else have an idea
WAIT A MINUTE! WOOOHOOO I FIGURED IT OUT. You were right that was the problem. I just needed to flip the arrow around. When I first shot it it seemed like it didnt work. thank you so much!!!
Check this asset it is well documented
Hye there.you are still replying this?I would like to ask ffew things.can I?