- Home /
 
Throw Object
Hello Unity3D i have a Question about objects.How can i throw a prefab object?For Example.Whenever i throw a particle prefab it throws just fine.But whenever i throw a ball or a stick the prefab appears but it goes nowhere.Why is it that i can only throw a prefab particle and not a prefab game-object?If anyone knows how i can throw a prefab game-object.Can you please tell me how?
Heres The Script If anyone Needs it
 var rocket : GameObject;  //our prefab
 var throwPower : float = 10; //power variable determines how fast this object will be "shot out"variable 
 var reloadTime = 10; //time to reload
 var timeBetweenShots = 10.0;
 private var nextFire : float =0.0;
 private var timestamp = -10.0;
 function Update ()
 
 {
 if (Input.GetKeyDown("1")&& Time.time > nextFire) {
          if (Time.time > timestamp + timeBetweenShots ) {
               Debug.Log("I'm firing now");
               timestamp = Time.time;
 
 
 Switch();
 
         }
     }   
 }    
 
 function Switch()
 {
     yield WaitForSeconds(1);
 
 
 
  
 clone = Instantiate(rocket, transform.position, transform.rotation); //the clone variable holds our instantiate action
  
 clone.velocity = transform.TransformDirection(Vector3.forward * throwPower); //applies force to our prefab using the "forward" position times our throwPower variable
 
 
  
 }
 
              Answer by cariaga · Dec 09, 2014 at 08:32 AM
replace
clone.velocity = transform.TransformDirection(Vector3.forward * throwPower);
with
 clone.AddForce(Vector3.forward* 500); //Moving projectile
 
               make sure your clone has a rigidbody
Thank You So $$anonymous$$uch!.The only thing is that i got to change the 500 into 10000 in order for it to move faster(if anyone else was planning of using this code as well..)
Answer by makaka-org · Jun 19, 2018 at 12:00 PM
Hey, Guys!
 Check my asset called Throw Control (documentation). 
 
 
 
Your answer
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
I can't go to unify wiki 2 Answers
Need help calling a script to another keep getting errors 1 Answer
Parsign error? 1 Answer