hey, I am not a programmer of any kind, which is why I need help with such a simple script.
I need to change the GetButtonDown input to the enter key. (I dont remember how to do this.)
And i would also like to change the direction of the bullets to where the character is facing.
var prefabBullet:Transform;
var shootForce:float;
function Update()
{
if(Input.GetKeyDown(KeyCode.Return))
{
var instanceBullet = Instantiate(prefabBullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.TransformDirection(transform.forward * shootForce));
}
}
The bullets are going in the direction the character is facing (unless your model is incorrectly made). Can you explain what is happening?
I don’t usually AddForce to start a projectile. In the example for Instantiate they use:
instanceBullet.velocity = transform.TransformDirection(Vector3.forward * shootForce); // Adapted to fit your code
Actually my character doesn’t rotate. only goes from left to right. I bought the 2D sidescroller pack from Unityprefabs.com. I regret it now, because it would have been easier to do on my own.
@Dman
Would you mind taking a look at my project, and making my character rotate when it moves. (as in turn the direction it is going.)
Its a 2d side scroller so probably wouldn’t be to hard.
Hi I’m too I’m working on a 2d platform game, its fully done almost, you can rotate and look up and down.
I’m on skype my sn is foxter888
Add me and I can screen share to show you how it works and send it to you just remember to say in skype that you meet new because of the forums so I remember that you are the one that needs help and don’t worry I’m not here for money but to help you out. Besides making friends.that share the same common programs and I use maya and zbrush too.in case you do use the same programs I could tell you what’s the best approach to have the models and animations working on unity 3d