class Shooting : ZilchComponent { //This script uses your spacebat to shot the ball/projectile [Property] var ShotSpeed : Integer = 20; function Initialize(init : CogInitializer) { var gamecamera = this.Space.FindObjectByName("Camera"); Zero.Connect(this.Space, Events.LogicUpdate, this.OnLogicUpdate); } function OnLogicUpdate(event : UpdateEvent) { var spawnPosition = this.Owner.Transform.Translation; //Change Archetype.Dodgeball to whatever projectile you are using var archetypeToSpawn = Archetype.DodgeBall; if(Zero.Keyboard.KeyIsPressed(Keys.Space)) { var createdBall = this.Space.CreateAtPosition(archetypeToSpawn, spawnPosition); //if the sprite is facing left then the projectile will shoot left here if(this.Owner.Sprite.FlipX == true) { createdBall.RigidBody.Velocity = -this.Owner.Orientation.WorldForward * this.ShotSpeed; createdBall.Sprite.FlipX = true; } //otherwise it will shoot to the right else { createdBall.RigidBody.Velocity = this.Owner.Orientation.WorldForward * this.ShotSpeed; } } } }