- Home /
 
              This question was 
             closed Jun 29, 2017 at 09:40 AM by 
             hexagonius for the following reason: 
             
 
            Unity Answers is about Unity, not code conversion
 
               Question by 
               Ajmcpro · Jun 28, 2017 at 10:11 PM · 
                c#javascriptscripting problemballturret  
              
 
              I need help converting this script from zilch to js
[Property] var Projectile : Archetype = Archetype.Find("ball");
 function Initialize(init : CogInitializer)
 {
     Zero.Connect(this.LevelSettings, Events.MouseDown, this.OnMouseDown);
 }
 function OnMouseDown (event : ViewportMouseEvent)
 {
     var mousePosition = event.ToWorldZPlane(0);
     var spawnPosition = this.Owner.Transform.Translation;
     var targetDirection = mousePosition - spawnPosition;
     var createdProjectile = this.Space.CreateAtPosition(this.Projectile, spawnPosition);
     targetDirection = Math.Normalize(targetDirection);
     var fireSpeed = 20.0;
     var fireVelocity = targetDirection * fireSpeed;
     createdProjectile.RigidBody.Velocity = fireVelocity;
 }
 
              
               Comment