- Home /
 
              This question was 
             closed Aug 20, 2012 at 05:14 PM by 
             tigerfoot for the following reason: 
             
 
            Dont need an answer anymore
 
               Question by 
               tigerfoot · Aug 20, 2012 at 02:18 AM · 
                aimtrajectoryarrow  
              
 
              Arrow visual aim helper
Hey,
I need to implement a visual aim helper. Something similar to the one in Angry Birds games. While a player aims i want something like a line to show the arrow trajectory when launched.
Lets say i need that line to show a second of a flight of my arrow when launched. It could be shown as a line or as dots(AngryBirds). Does anyone know how to code that?
This is my code that moves an arrow:
 #pragma strict
 var gravityVar : float;
 var powerMultiplier : float;
 private var arrowPower : float;
 static var gravity : Vector3; //let's assume it's always down
 var drag : float = 0.01; // A coefficient for the amount of drag in the medium
 var velocity : Vector3; //The movement to make this contains direction and speed
 private var moving : boolean = true;
 
 function Start(){
     gravity = Vector3.up * -gravityVar;
     //arrowPower = GetComponent(aim).power;
     
     arrowPower = GameObject.Find("archer").GetComponent(aim).power;
      
     velocity = transform.forward*-(arrowPower*powerMultiplier);
 }
 
 function Update() {
     if(moving) {
         velocity += gravity;
         velocity -= velocity.sqrMagnitude * drag * velocity.normalized;
         var amountToMove = velocity * Time.deltaTime;
         
         transform.LookAt(transform.position + amountToMove); //look where you're going
         transform.position += amountToMove; //go there
     }
 }
 
              
               Comment