void ICmpUpdatable.OnUpdate() { RigidBody r = this.GameObj.RigidBody; Transform t = this.GameObj.Transform; //initialize where object starts if (initCoord.Y == 0) { initCoord.Y = this.GameObj.Transform.RelativePos.Y; } //if the object falls below the threshold apply a local force if (t.RelativePos.Y > initCoord.Y - 100) { r.ApplyLocalImpulse(Vector2.UnitY * -1.0f * force); } }
protected virtual GameObject NewProjectile() { Vector3 firingOffset = new Vector3(sprite.Rect.Top); GameObject bullet = ProjectilePrefab.Res.Instantiate(GameObj.Transform.Pos + GameObj.Transform.GetWorldVector(firingOffset), GameObj.Transform.Angle); if (parentBody != null) { RigidBody body = bullet.GetComponent <RigidBody>(); body.LinearVelocity += parentBody.LinearVelocity; parentBody.ApplyLocalImpulse(Vector2.UnitY * Recoil * parentBody.Mass); } Flag parentFlag = GameObj.Parent.GetComponent <Flag>(); if (parentFlag != null) { bullet.GetComponent <Flag>().Color = parentFlag.Color; } return(bullet); }
void ICmpUpdatable.OnUpdate() { RigidBody body = this.GameObj.RigidBody; Transform transform = this.GameObj.Transform; if (healthPts <= 0) { this.GameObj.Dispose(); } if (DualityApp.Keyboard[Key.Left]) { body.LinearVelocity = Vector2.UnitX * distance * -1.0f; } else if (DualityApp.Keyboard[Key.Right]) { body.LinearVelocity = Vector2.UnitX * distance; } else if (DualityApp.Keyboard[Key.Space]) { body.ApplyLocalImpulse(Vector2.UnitY * -force * body.Mass); } }