public override void _Ready() { FpLandSfx = GetNode <AudioStreamPlayer>("FpLandSfx"); TpLandSfx = GetNode <AudioStreamPlayer3D>("TpLandSfx"); FpWallKickSfx = GetNode <AudioStreamPlayer>("FpWallKickSfx"); TpWallKickSfx = GetNode <AudioStreamPlayer3D>("TpWallKickSfx"); FpThrowSfx = GetNode <AudioStreamPlayer>("FpThrowSfx"); TpThrowSfx = GetNode <AudioStreamPlayer3D>("TpThrowSfx"); FpPickupSfx = GetNode <AudioStreamPlayer>("FpPickupSfx"); TpPickupSfx = GetNode <AudioStreamPlayer3D>("TpPickupSfx"); FpRocketFireSfx = GetNode <AudioStreamPlayer>("FpRocketFireSfx"); TpRocketFireSfx = GetNode <AudioStreamPlayer3D>("TpRocketFireSfx"); FpHitsoundSfx = GetNode <AudioStreamPlayer>("FpHitsoundSfx"); FpKillsoundSfx = GetNode <AudioStreamPlayer>("FpKillsoundSfx"); FpThunderboltFireSfx = GetNode <AudioStreamPlayer>("FpThunderboltFireSfx"); TpThunderboltFireSfx = GetNode <AudioStreamPlayer3D>("TpThunderboltFireSfx"); FpScattershockFireSfx = GetNode <AudioStreamPlayer>("FpScattershockFireSfx"); TpScattershockFireSfx = GetNode <AudioStreamPlayer3D>("TpScattershockFireSfx"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { SeeableArea = (Area)GetNode("LineOfSight"); firingTimer = (Timer)GetNode("FiringTimer"); bulletContainer = GetNode("Bullet Container"); bullet = ResourceLoader.Load <PackedScene>("res://Scenes/Bullet.tscn"); rayCast = (RayCast)GetNode("RayCast"); muzzleFlashLight = GetNode("Firing light"); // Check if enemies are human IsHuman = ((Global)GetNode("/root/Global")).HumanEnemies; // Load accordingly if (IsHuman) { ((Spatial)GetNode("Human Nodes")).Visible = true; ((Spatial)GetNode("Wasp Nodes")).Visible = false; deathAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Death audio"); firingAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Firing audio"); hitAudio = (AudioStreamPlayer3D)GetNode("Human Nodes/Hit audio"); sprite = (Sprite3D)GetNode("Human Nodes/Sprite3D"); animationPlayer = (AnimationPlayer)GetNode("Human Nodes/Sprite3D/AnimationPlayer"); } else { ((Spatial)GetNode("Wasp Nodes")).Visible = true; ((Spatial)GetNode("Human Nodes")).Visible = false; deathAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Death audio"); firingAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Firing audio"); hitAudio = (AudioStreamPlayer3D)GetNode("Wasp Nodes/Hit audio"); sprite = (Sprite3D)GetNode("Wasp Nodes/Sprite3D"); animationPlayer = (AnimationPlayer)GetNode("Wasp Nodes/Sprite3D/AnimationPlayer"); } }
public override void _Ready() { _audioNode = GetNode <AudioStreamPlayer3D>("Audio_Stream_Player"); _audioNode.Connect("finished", this, nameof(SoundFinished)); _audioNode.Stop(); _globals = GetNode <Globals>("/root/Globals"); }
virtual public void Spawn(Player p, string nodeName) { PackedScene PackedScene = (PackedScene)ResourceLoader.Load(_weaponResource); _weaponMesh = (MeshInstance)PackedScene.Instance(); p.Head.AddChild(_weaponMesh); _playerOwner = p; _weaponMesh.Translation = _weaponPosition; _weaponMesh.Name = nodeName; _weaponMesh.Visible = false; _shootSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ShootSound"); if (_weaponMesh.HasNode("MuzzleFlash")) { _muzzleFlash = (Sprite3D)_weaponMesh.GetNode("MuzzleFlash"); } if (_weaponMesh.HasNode("ReloadSound")) { _reloadSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ReloadSound"); } // projectile mesh if (_weaponShotType == WEAPONSHOTTYPE.PROJECTILE || _weaponShotType == WEAPONSHOTTYPE.GRENADE) { _projectileScene = (PackedScene)ResourceLoader.Load(_projectileResource); } }
public override void _Ready() { audioPlayer = GetNode <AudioStreamPlayer3D>("AudioStreamPlayer3D"); animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); coinCollision = GetNode <CollisionShape>("CoinCollision"); timer = GetNode <Timer>("Timer"); }
override public void Spawn(Player p, string nodeName) { base.Spawn(p, nodeName); _spinDownSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("SpinDownSound"); _spinUpSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("SpinUpSound"); _idleSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("IdleSound"); }
public void PlaySoundEffect(string effect, float volume = 1.0f) { // TODO: make these sound objects only be loaded once var sound = GD.Load <AudioStream>(effect); // Find a player not in use or create a new one if none are available. var player = otherAudioPlayers.Find(nextPlayer => !nextPlayer.Playing); if (player == null) { // If we hit the player limit just return and ignore the sound. if (otherAudioPlayers.Count >= Constants.MAX_CONCURRENT_SOUNDS_PER_ENTITY) { return; } player = new AudioStreamPlayer3D(); player.UnitDb = GD.Linear2Db(volume); player.MaxDistance = 100.0f; player.Bus = "SFX"; AddChild(player); otherAudioPlayers.Add(player); } player.Stream = sound; player.Play(); }
public void Spawn(Node camera, string Name) { PackedScene PackedScene = (PackedScene)ResourceLoader.Load(_weaponResource); _weaponMesh = (MeshInstance)PackedScene.Instance(); camera.AddChild(_weaponMesh); _weaponMesh.Translation = this.SpawnTranslation; _weaponMesh.SetName(Name); _weaponMesh.SetVisible(false); shootSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ShootSound"); if (_weaponMesh.HasNode("MuzzleFlash")) { muzzleFlash = (Sprite3D)_weaponMesh.GetNode("MuzzleFlash"); } if (_weaponMesh.HasNode("ReloadSound")) { reloadSound = (AudioStreamPlayer3D)_weaponMesh.GetNode("ReloadSound"); } // projectile mesh if (_weaponType == WeaponType.Projectile || _weaponType == WeaponType.Grenade) { _projectileScene = (PackedScene)ResourceLoader.Load(_projectileResource); } GD.Print("Loaded " + Name); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { openAudio = (AudioStreamPlayer3D)GetNode("Audio open"); closeAudio = (AudioStreamPlayer3D)GetNode("Audio close"); animation = (AnimationPlayer)GetNode("AnimationPlayer"); Timer = (Timer)GetNode("Timer"); }
public AudioStreamPlayer3D AddSoundInstance(Actor actor, Guid id, AudioStream audioClip, MediaStateOptions options) { float offset = options.Time.GetValueOrDefault(); if (options.Looping != null && options.Looping.Value && audioClip.GetLength() != 0.0f) { offset = offset % audioClip.GetLength(); } if (offset < audioClip.GetLength()) { var soundInstance = new AudioStreamPlayer3D(); actor.AddChild(soundInstance); soundInstance.Stream = audioClip; soundInstance.Seek(offset); soundInstance.UnitSize = 1.0f; soundInstance.EmissionAngleDegrees = 45.0f; //only affects multichannel sounds. Default to 50% spread, 50% stereo. soundInstance.MaxDistance = 1000000.0f; ApplyMediaStateOptions(actor, soundInstance, options, id, true); if (options.paused != null && options.paused.Value == true) { //start as paused soundInstance.Play(); soundInstance.StreamPaused = true; } else { //start as unpaused _unpausedSoundInstances.Add(new SoundInstance(id, actor)); soundInstance.Play(); soundInstance.StreamPaused = false; } return(soundInstance); } return(null); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { snd = GetNode <AudioStreamPlayer3D>("AudioStreamPlayer3D"); parent = GetNode <Enemy>(parentPath); barrel = GetNode <Position3D>("Barrel"); fireRate = (float)GD.RandRange(0.5f, 0.8f); }
public override void _Ready() { base._Ready(); var vr = ARVRServer.FindInterface("OpenVR"); if (vr != null && vr.Initialize()) { GetViewport().Arvr = true; GetViewport().Hdr = false; OS.VsyncEnabled = false; Engine.IterationsPerSecond = 90; } LeftController = GetNode <Controller>("./ARVROrigin/LeftController"); RightController = GetNode <Controller>("./ARVROrigin/RightController"); MatchTileStream = GetNode <MatchTileStream>("MatchTileStream"); TileMatchTimer = GetNode <Timer>("TileMatchTimer"); TileMatchCountdown = GetNode <TileMatchCountdown>("TileMatchCountdown"); ScoreBoard = GetNode <ScoreBoard>("ScoreBoard"); StartMenu = GetNode <Menu>("StartMenu"); GameOverMenu = GetNode <GameOverMenu>("GameOverMenu"); MatchSuccessSound = GetNode <AudioStreamPlayer3D>("MatchTileStream/MatchSuccessSound"); MatchFailSound = GetNode <AudioStreamPlayer3D>("MatchTileStream/MatchFailSound"); NextLevelSound = GetNode <AudioStreamPlayer3D>("MatchTileStream/NextLevelSound"); }
public override void _Process(float delta) { if (footStepTimer <= 0) { if ((Vector3)player.Get("direction") != Vector3.Zero && feet.IsColliding()) { // Get collided body group name Godot.Collections.Array collidedGroups = ((Node)feet.GetCollider()).GetGroups(); foreach (String group in collidedGroups) { if (footStepList.ContainsKey(group)) { Node footStepNode = footStepList[group]; if (footStepNode.GetChildCount() > 0) { // Play audio int randomIndex = (int)GD.RandRange(0, footStepNode.GetChildCount() - 1); AudioStreamPlayer3D audio = (AudioStreamPlayer3D)footStepNode.GetChild(randomIndex); audio.Play(); // Sync player speed with audio loop footStepTimer = (1 - (0.06f * (float)player.Get("normalSpeed"))); break; } } } } } else { footStepTimer -= delta; } }
public override void _Ready() { animation = ((AnimationPlayer)GetNode("AnimationPlayer")); audio = ((AudioStreamPlayer3D)GetNode("AudioStreamPlayer3D")); sprite = (Sprite3D)GetNode("Barrel"); timer = (Timer)GetNode("Timer"); area = (Area)GetNode("Explosion Area"); collisionShape = (CollisionShape)GetNode("CollisionShape"); explosionMesh = (MeshInstance)GetNode("Explosion mesh"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { snd = GetNode <AudioStreamPlayer3D>("AudioStreamPlayer3D"); player = GetNode <Spatial>("/root/Spatial/Player"); fireRate = (float)GD.RandRange(fireRateMin, fireRateMax); if (startupDelay) { time -= fireRate; } }
//private SpeechSynthesizer voice; // Called when the node enters the scene tree for the first time. public override void _Ready() { speachPlayer = GetNode <AudioStreamPlayer3D>("SpeachPlayer"); animationTree = GetNode <AnimationTree>("AnimationTree"); //voice = new SpeechSynthesizer(); //voice.Rate = -1; //voice.VisemeReached += VisemeReached; //SetLanguage(); }
public override void _Ready() { bot = (PhysicalEntity)GetParent(); frontSensor = (RayCast)GetNode("Sensors/Front"); this.destroy = (AudioStreamPlayer3D)GetNode("SfxDestroy"); this.detect = (AudioStreamPlayer3D)GetNode("SfxDetect"); this.sensors = (Spatial)GetNode("Sensors"); AudioStreamPlayer3D engine = (AudioStreamPlayer3D)GetNode("Engine"); engine.Play(); }
public override void _Ready() { _game = GetTree().Root.GetNode("Game") as Game; _head = (Spatial)GetNode("Head"); _stairCatcher = (RayCast)GetNode("StairCatcher"); _mesh = GetNode("MeshInstance") as MeshInstance; _feet = GetNode("Feet") as RayCast; _dieSound = GetNode("DieSound") as AudioStreamPlayer3D; _grenTimer = GetNode("GrenTimer") as AudioStreamPlayer; _jumpSound = GetNode("JumpSound") as AudioStreamPlayer3D; }
private void death(float delta) { if (health <= 0) { AudioStreamPlayer3D die = ((AudioStreamPlayer3D)GetNode("audio/die/0")); if (!die.Playing) { die.PitchScale = (float)GD.RandRange(0.9, 1.1); die.Play(); } } }
// Called when the node enters the scene tree for the first time. public override void _Ready() { globals = (Globals)GetNode("/root/Globals"); // instantiate the players tankscene = ResourceLoader.Load("res://Tank.tscn") as Godot.PackedScene; // load audio hitsound = (AudioStreamPlayer3D)GetNode("hitsound"); // signal for HUD to listen for AddUserSignal("tanks_created"); Tank localplayer = (Tank)tankscene.Instance(); localplayer.SetName(GetTree().GetNetworkUniqueId().ToString()); localplayer.SetNetworkMaster(GetTree().GetNetworkUniqueId()); Tank remoteplayer = (Tank)tankscene.Instance(); remoteplayer.SetName(globals.otherPlayerId.ToString()); remoteplayer.SetNetworkMaster(globals.otherPlayerId); Vector3 serverspawn = new Vector3(12, 0, 12); Vector3 clientspawn = new Vector3(-12, 0, -12); // set spawn positions if (GetTree().IsNetworkServer()) { localplayer.Translate(serverspawn); remoteplayer.Translate(clientspawn); } else { localplayer.Translate(clientspawn); remoteplayer.Translate(serverspawn); } localplayer.SetRespawn(); remoteplayer.SetRespawn(); AddChild(localplayer); AddChild(remoteplayer); // connect signals for tanks localplayer.Connect("bullet_fired", this, nameof(newBullet)); remoteplayer.Connect("bullet_fired", this, nameof(newBullet)); localplayer.SetActiveCam(); // Notify the HUD that the tanks are available EmitSignal("tanks_created"); }
public void Explode() { if (IsLocal) { if ((Player as Spatial).Translation.DistanceTo(Translation) <= RocketJumper.MaxRocketDistance) { AffectedBodies.Add(Player); } } foreach (Node _Body in AffectedBodies) { if (_Body is IPushable Body) { float Distance = Clamp(Translation.DistanceTo(Body.Translation) - RocketJumper.MinRocketDistance, 1, RocketJumper.MaxRocketDistance); float Power = RocketJumper.MaxRocketDistance / Distance / RocketJumper.MaxRocketDistance; Vector3 Push = ((Body.Translation - Translation) / RocketJumper.MaxRocketDistance).Normalized() * RocketJumper.MaxRocketPush * Power; { Vector3 Flat = Push.Flattened(); Flat *= RocketJumper.RocketHorizontalMultiplyer; Push.x = Flat.x; Push.z = Flat.z; } Push.y /= RocketJumper.RocketVerticalDivisor; Body.ApplyPush(Push); if (Body is Player AffectedPlayer) { AffectedPlayer.RecoverPercentage = 0; } } } AffectedBodies.Clear(); AudioStreamPlayer3D ExplodeSfxInstance = ExplodeSfx.Instance() as AudioStreamPlayer3D; ExplodeSfxInstance.Play(); ExplodeSfxInstance.Translation = Translation; World.EntitiesRoot.AddChild(ExplodeSfxInstance); CPUParticles ParticleSystem = ExplodeParticles.Instance() as CPUParticles; ParticleSystem.Translation = Translation; ParticleSystem.Emitting = true; World.EntitiesRoot.AddChild(ParticleSystem); QueueFree(); }
public override void _Ready() { FpLandSfx = GetNode <AudioStreamPlayer>("FpLandSfx"); TpLandSfx = GetNode <AudioStreamPlayer3D>("TpLandSfx"); FpWallKickSfx = GetNode <AudioStreamPlayer>("FpWallKickSfx"); TpWallKickSfx = GetNode <AudioStreamPlayer3D>("TpWallKickSfx"); FpThrowSfx = GetNode <AudioStreamPlayer>("FpThrowSfx"); TpThrowSfx = GetNode <AudioStreamPlayer3D>("TpThrowSfx"); FpPickupSfx = GetNode <AudioStreamPlayer>("FpPickupSfx"); TpPickupSfx = GetNode <AudioStreamPlayer3D>("TpPickupSfx"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { // Get references to parts of tanks trackleft = (MeshInstance)GetNode("TrackLeft"); trackright = (MeshInstance)GetNode("TrackRight"); body = (MeshInstance)GetNode("Body"); turret = (KinematicBody)GetNode("Turret"); gun = (MeshInstance)GetNode("Turret/TurretMesh/Gun"); // load sounds trackmovementsound = (AudioStreamPlayer3D)GetNode("SoundGroup/TrackMovementSound"); firesound = (AudioStreamPlayer3D)GetNode("SoundGroup/FireSound"); explodesound = (AudioStreamPlayer3D)GetNode("SoundGroup/ExplosionSound"); soundgroup = GetNode("SoundGroup"); // load cameras thirdpersoncamera = (Camera)GetNode("ThirdPersonCam"); firstpersoncamera = (Camera)GetNode("Turret/TurretMesh/Gun/BulletSpawn/Camera"); // reference to explosion for death explosion = (Particles)GetNode("Explosion/Particles"); explosion.SetEmitting(false); // Load bullet scene bulletscene = ResourceLoader.Load("res://Bullet.tscn") as Godot.PackedScene; // Set a color for the tank setTankColor(defaultTankColor); health = maxhealth; // add signals AddUserSignal("dec_local_health"); AddUserSignal("respawn"); AddUserSignal("bullet_fired"); // connect respawn timer AddChild(deathtimer); deathtimer.Connect("timeout", this, "Respawn"); deathtimer.SetWaitTime(RESPAWN_SECONDS); SetProcess(true); // required to appear at spawn MoveAndSlide(new Vector3(0, 0, 0), new Vector3(0, 1, 0), true); // enforce no flying tanks issue #20 originalY = Transform.origin.y; }
public override void _Ready() { bulletSystem = GetNode <BulletSystem>("BulletSystem"); laserStream = GetNode <AudioStreamPlayer3D>("LaserStream"); animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); bulletSystem.container = GetParent(); bulletSystem.Connect(nameof(BulletSystem.Fired), this, nameof(_OnFired)); Connect("area_entered", this, nameof(_OnAreaEntered)); ComputeRectLimits(); initialPosition = GlobalTransform.origin; }
public void draw() { if (!weaponNode.Visible) { weaponNode.Show(); // Audio. AudioStreamPlayer3D draw = ((AudioStreamPlayer3D)audioNode.GetNode("draw")); draw.PitchScale = (float)GD.RandRange(0.9, 1.1); draw.Play(); } // Notify weapon update GameState.instance.EmitSignal(nameof(GameState.updateWeapon), weaponName, bullets, ammo); }
public void reload() { if (reloadWeapon == false && bullets < maxBullets && ammo > 0) { reloadWeapon = true; // Hide crosshair crosshair.Hide(); // Audio. AudioStreamPlayer3D reload = ((AudioStreamPlayer3D)audioNode.GetNode("reload")); reload.PitchScale = (float)GD.RandRange(0.9, 1.1); reload.Play(.30f); animation.Play("reload"); } }
// Handle player jump private void jump(float delta) { if (input["jump"] == 1) { if (this.IsOnFloor()) { velocity.y = jumpHeight; wasJumping = true; AudioStreamPlayer3D jump = ((AudioStreamPlayer3D)GetNode("audio/jump/0")); if (!jump.Playing) { jump.PitchScale = (float)GD.RandRange(0.9, 1.1); jump.Play(0); } } } }
private void SetupSound(int type) { AudioStream open = null; AudioStream close = null; switch (type) { case 1: open = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/doormv1.wav"); close = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/drclos4.wav"); break; case 2: open = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/hydro1.wav"); close = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/hydro2.wav"); break; case 3: open = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/stndr1.wav"); close = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/stndr2.wav"); break; case 4: open = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/ddoor1.wav"); close = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/ddoor2.wav"); break; default: // FIXME test open = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/doormv1.wav"); close = ResourceLoader.Load <AudioStream>("res://Assets/Sounds/doors/drclos4.wav"); break; } if (open != null && close != null) { _sndOpen = new AudioStreamPlayer3D(); _sndClose = new AudioStreamPlayer3D(); _sndOpen.Stream = open; _sndClose.Stream = close; _sndOpen.Name = "sndOpen"; _sndClose.Name = "sndClose"; AddChild(_sndOpen); AddChild(_sndClose); } }
public static void SpawnOneShotSound(AudioStream sample, Node contextNode, Vector3 location) { if (sample == null) { return; } var r = contextNode.GetTree().CurrentScene; var c = r.GetChildCount(); var existingCount = 0; AudioStreamPlayer3D availExisting = null; for (int i = 0; i < c; ++i) { var n = r.GetChild(i); if (n is AudioStreamPlayer3D) { existingCount++; if (!((AudioStreamPlayer3D)n).IsPlaying()) { availExisting = (AudioStreamPlayer3D)n; break; } } } if (availExisting == null && existingCount < 10) { availExisting = new AudioStreamPlayer3D(); contextNode.GetTree().CurrentScene.AddChild(availExisting); } if (availExisting != null) { availExisting.SetGlobalLocation(location); availExisting.Stream = sample; availExisting.UnitDb = 15; availExisting.Play(); } }
public Actor(XElement spawn) : base() { XML = spawn; Name = XML?.Attribute("Actor")?.Value; if (!string.IsNullOrWhiteSpace(Name)) { CollisionShape.Name = "Collision " + Name; ActorXML = Assets.XML.Element("VSwap")?.Element("Objects").Elements("Actor").Where(e => e.Attribute("Name")?.Value?.Equals(Name, System.StringComparison.InvariantCultureIgnoreCase) ?? false).FirstOrDefault(); Ambush = ActorXML.IsTrue("Ambush"); } Direction = Direction8.From(XML?.Attribute("Direction")?.Value); AddChild(Speaker = new AudioStreamPlayer3D() { Name = Name + " speaker", Transform = new Transform(Basis.Identity, new Vector3(0f, Assets.HalfWallHeight, 0f)), Bus = "3D", }); State = Assets.States[XML?.Attribute("State")?.Value]; AddChild(DebugFloor = new MeshInstance() { Name = Name + " Debug Floor", Mesh = new QuadMesh() { Size = new Vector2(Assets.WallWidth, Assets.WallWidth), }, MaterialOverride = new SpatialMaterial() { AlbedoColor = Color.Color8(255, 0, 0, 128), FlagsUnshaded = true, FlagsDoNotReceiveShadows = true, FlagsDisableAmbientLight = true, FlagsTransparent = true, ParamsCullMode = SpatialMaterial.CullMode.Disabled, ParamsSpecularMode = SpatialMaterial.SpecularMode.Disabled, AnisotropyEnabled = true, RenderPriority = 1, }, Transform = new Transform(new Basis(Vector3.Right, Mathf.Pi / 2f).Orthonormalized(), new Vector3(0f, Assets.PixelHeight, 0f)), }); }