public override void _Ready() { age = 0; exploded = false; bulletParent = (Position3D)GetParent(); explosion = bulletParent.GetNode <MeshInstance>("Explosion"); }
private void Explode() { if (!exploded) { explosionTime = age; exploded = true; explosion.Visible = true; var sound = bulletParent.GetNode <AudioStreamPlayer3D>("ExplosionNoise"); sound.Play(); } }
private void ShootVaguelyTowards(Vector3 where) { var target = where; target.x += (float)(inaccuracyMax * rng.NextDouble()); target.x -= (float)(inaccuracyMax * rng.NextDouble()); target.z += (float)(inaccuracyMax * rng.NextDouble()); target.z -= (float)(inaccuracyMax * rng.NextDouble()); Position3D bullet = (Position3D)bulletScene.Instance(); bullet.LookAtFromPosition( this.Translation, target, Vector3.Up ); var newBulletPhysics = bullet.GetNode <PhysicsBody>("BulletPhysics"); newBulletPhysics.SetCollisionLayerBit(2, true); world.AddChild(bullet); }