Hi there. I am new to unity, so i really need help with start My question is :
i have a character with bow and arrow’s. I have animation when he shoots, but how to make the bow fly in direction ? It has to collide with object’s it hits. What should be direction ? I would really like to make a croshair in front of my character, and every script, tutorial i have seen… it’s not good enough.
Should i be working on javascript for arrow ? or make a C# file ?
Doesn't matter which language you use. Just use the one you're comfortable with. If you search this site for 'arrow' you'll find a lot of questions very similar to this. Short version - instantiate the arrow at the bow's position with the bow's rotation, give it a velocity, when it hits something, disable its movement.
thanks for reply, but as i already told.. nothing helpfull is out there. i need help from point 0. I just found that a rigidbody should be attached to arrows joint, not the arrows its self ? am i right ?
Start with basic objects and play with instantiate to achieve what exactly you’re looking for.
Here is the basic Java code for instantiating an object from the object that holds this script.
Most/all of the term other users will suggest to you as solutions will be located in the Unity Script Reference. A reference, lexicon and bible. Unity - Scripting API:
Good luck and best wishes!
// Instantiate a rigidbody then set the velocity
var projectile : Rigidbody;
function Update () {
// Ctrl was pressed, launch a projectile
if (Input.GetButtonDown(“Fire1”)) {
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * 10);
}
This is a basic code for what you are doing. I suggest you take a look at the Unity3d script reference if you have any questions or to trouble shoot any mistakes in the code.
This is a basic code for what you are doing. I suggest you take a look at the Unity3d script reference if you have any questions or to trouble shoot any mistakes in the code.
You're accessing arrow before it's set, you're disabling gravity on it (?), you're not giving it a meaningful rotation, and you've got 'muzzle' stuff going on. Not that varnames do anything to logic but it's best not to confuse the programmer.
I'm sure if he's developing an RPG, he'd have a variable set for arrow, and I wouldn't be required to do so for him. Therefore, setting the gravity for a variable that he should already have would cause no problem.
Ah well one more thing. This didnt really help me much since the arrow just falls down after animating shoot…
Question : rigidbody and scripts should be " attached " to joint that holds the arrow ? ( right) not to a mesh, since it is locked after i applied skeleton on it. Arrow falls only if script is attached to joint now the mesh, not even the controler.
Doesn't matter which language you use. Just use the one you're comfortable with. If you search this site for 'arrow' you'll find a lot of questions very similar to this. Short version - instantiate the arrow at the bow's position with the bow's rotation, give it a velocity, when it hits something, disable its movement.
– Loiusthanks for reply, but as i already told.. nothing helpfull is out there. i need help from point 0. I just found that a rigidbody should be attached to arrows joint, not the arrows its self ? am i right ?
– Neroner23