class DodgeBall : ZilchComponent { //This script uses your left mouse button to shot the ball/projectile [Property] var ShotSpeed : Integer = 1; function Initialize(init : CogInitializer) { var gamecamera = this.Space.FindObjectByName("Camera"); Zero.Connect(gamecamera, Events.MouseDown, this.OnKeyDown); } function OnKeyDown(event : ViewportMouseEvent) { var spawnPosition = this.Owner.Transform.Translation + this.Owner.Orientation.WorldForward; //Change Archetype.Dodgeball to whatever projectile you are using var archetypeToSpawn = Archetype.DodgeBall; var createdBall = this.Space.CreateAtPosition(archetypeToSpawn, spawnPosition); createdBall.RigidBody.Velocity = this.Owner.Orientation.WorldForward * this.ShotSpeed; } }