void Awake() { rayCast = GameObject.Find("Main Camera").GetComponent <RayCast>(); woodText = GameObject.Find("Wood").GetComponent <Text> (); berriesText = GameObject.Find("Berries").GetComponent <Text> (); rockText = GameObject.Find("Rock").GetComponent <Text> (); }
public Vector3 GetTeleportLocation() { // get weighted sum of all Vector3 resultant = Vector3.Zero; Spatial detector = GetNode <Spatial>("Detectors"); RayCast bottomRaycast = detector.GetNode <RayCast>("bottom"); bottomRaycast.ForceRaycastUpdate(); if (!bottomRaycast.IsColliding()) { Util.DrawSphere(bottomRaycast.GetCollisionPoint(), detector); } foreach (RayCast cast in _detectorList) { cast.ForceRaycastUpdate(); if (cast.IsColliding()) { // get collision point in local coordinates to detector spatial in middle of sword Vector3 collisionVector = cast.Transform.XformInv(cast.GetCollisionPoint()); resultant += cast.GetCollisionNormal() * (1 - Mathf.Min(collisionVector.Length(), _minDetectorWeight)); } } // return average of normals return(Transform.origin + resultant.Normalized()); }
private void InputSpawn() { RayCast frontRayCast = _moveWrapper.GetChild <RayCast>(1); RayCast frontGroundRayCast = _moveWrapper.GetChild <RayCast>(2); var frontGround = (Node)frontGroundRayCast.GetCollider(); string name = NameGetter.FromCollision(frontGround); //check the player requested a spawn on an empty tile above ground if (frontGround != null) { if (Input.IsActionJustPressed("ui_select") && !frontRayCast.IsColliding() && (name == "GridMap" || name == "pot")) { //spawn a flower in front of the player Spatial flowerInstance = (Spatial)_flowerPlatform.Instance(); flowerInstance.Translation = Translation + _moveWrapper.Translation + moveWrapper.SPEED * FacingVec(); GetParent().AddChild(flowerInstance); if (name == "pot") { ((moveWrapper)frontGround).planted = true; } } } }
private void LoadResources() { //Regestir for the event callback for the placing of the rooms PlaceExitEvent.RegisterListener(InitExitWall); //Init he raycasts of the room walls used for creating the room roofRay = GetNode <RayCast>("Roof/RoofRay"); floorRay = GetNode <RayCast>("Floor/FloorRay"); frontRay = GetNode <RayCast>("FrontWall/FrontRay"); backRay = GetNode <RayCast>("BackWall/BackRay"); leftRay = GetNode <RayCast>("LeftWall/LeftRay"); rightRay = GetNode <RayCast>("RightWall/RightRay"); //Get the reference to the walls frontWall = GetNode <KinematicBody>("FrontWall"); backWall = GetNode <KinematicBody>("BackWall"); leftWall = GetNode <KinematicBody>("LeftWall"); rightWall = GetNode <KinematicBody>("RightWall"); roofWall = GetNode <KinematicBody>("Roof"); floorWall = GetNode <KinematicBody>("Floor"); //Get the refferences to the platform sets platformSet1Scene = ResourceLoader.Load("res://Scenes/PlatformSet1.tscn") as PackedScene; platformSet2Scene = ResourceLoader.Load("res://Scenes/PlatformSet2.tscn") as PackedScene; platformSet3Scene = ResourceLoader.Load("res://Scenes/PlatformSet3.tscn") as PackedScene; platformSet4Scene = ResourceLoader.Load("res://Scenes/PlatformSet4.tscn") as PackedScene; platformSet5Scene = ResourceLoader.Load("res://Scenes/PlatformSet5.tscn") as PackedScene; platformSet6Scene = ResourceLoader.Load("res://Scenes/PlatformSet6.tscn") as PackedScene; platformSet7Scene = ResourceLoader.Load("res://Scenes/PlatformSet7.tscn") as PackedScene; //Grab the reference to the exit walls scene exitWallScene = ResourceLoader.Load("res://Scenes/ExitWall.tscn") as PackedScene; }
// Use this for initialization void Start() { if (instance == null) { instance = this; } }
/// <summary> /// Converts a <see cref="Ray"/> into a remote <see cref="RayCast"/>. /// </summary> /// <param name="input">The ray to be converted.</param> /// <param name="output">The converted ray cast.</param> /// <param name="distance">The distance used to calculate the end position on the converted ray cast.</param> /// <param name="hitCollection">The hit collection mode to set on the converted ray cast.</param> /// <param name="maxHits">The maximum collected hits to set on the converted ray cast.</param> /// <param name="collisionMask">The collision mask to set on the converted ray cast.</param> public static void ToRemote(this Ray input, out RayCast output, float distance, HitCollectionPolicy hitCollection = HitCollectionPolicy.ClosestHits, int maxHits = 1024, uint collisionMask = 0xFFFFFFFF) { input.Position.ToRemote(out Double3 starPos); input.GetPoint(distance, out var terminus); terminus.ToRemote(out Double3 endPos); output = new RayCast(starPos, endPos, distance, hitCollection, maxHits, collisionMask); }
// Ready function, called once at the beginning of the scene when all children are ready public override void _Ready() { // Assign required nodes objectBody = GetNode <StaticBody>("ViewportContainer/Viewport/ObjectRoot/Object1"); ray = GetNode <RayCast>("ViewportContainer/Viewport/ObjectRoot/HiddenLineRay"); freeCameraRoot = GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/CameraRoot"); orthoCameraRoot = GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/OrthoCameraRoot"); // Populate the list of planes with the nodes of each BoxPlaneControl object planes = new Spatial[PLANE_COUNT] { GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/FrontPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/RightPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/BackPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/LeftPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/TopPlaneControl"), GetNode <Spatial>("ViewportContainer/Viewport/ObjectRoot/BottomPlaneControl") }; // All faces are hidden at first isFaceShown = new bool[PLANE_COUNT] { false, false, false, false, false, false }; // Initialize the required static variables in the PlaneControl class PlaneControl.Initialize(objectBody.GetChild <MeshInstance>(0), ray, PlaneControl.ORTHOGRAPHIC); // Set the display size PlaneControl.SetScreenSize(PLANE_X_SCALE, PLANE_Y_SCALE, MAX_FOCUS); // Set the zoom of the PlaneControl class // A zoom value of 1 is set because this scene requires orthographic projection (without scaling to screen size) PlaneControl.SetZoom(MAX_FOCUS); // Set the projection colours ProjectionRoot.SetColours(true, false); }
public void PrimaryFire(double Sens) { if (Sens > 0d && !IsFiring) { IsFiring = true; if (Inventory[InventorySlot] != null) { //Assume for now that all primary fire opertations are to build RayCast BuildRayCast = GetNode("SteelCamera/RayCast") as RayCast; if (BuildRayCast.IsColliding()) { Structure Hit = BuildRayCast.GetCollider() as Structure; if (Hit != null) { Building.Request(Hit, Inventory[InventorySlot].Type, 1); //ID 1 for now so all client own all non-default structures } } } } if (Sens <= 0d && IsFiring) { IsFiring = false; } }
public override void _Ready() { AddToGroup("PoV"); raycast = (RayCast)GetNode("RayCast"); Setup(); Player.Instance.pov = this; }
private void SetTargetPoint() { // Generate a plane that intersects the transform's position with an upwards normal. Plane playerPlane = new Plane(Vector3.back, new Vector3(0, 0, 0)); //transform.position + // Generate a ray from the cursor position Ray RayCast; if (Input.touchCount > 0) { RayCast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); } else { RayCast = Camera.main.ScreenPointToRay(Input.mousePosition); } // Determine the point where the cursor ray intersects the plane. float HitDist = 0; // If the ray is parallel to the plane, Raycast will return false. if (playerPlane.Raycast(RayCast, out HitDist)) //playerPlane.Raycast { // Get the point along the ray that hits the calculated distance. Vector3 RayHitPoint = RayCast.GetPoint(HitDist); transform.position = new Vector3(RayHitPoint.x, RayHitPoint.y, targetZ); } }
// Called when the node enters the scene tree for the first time. public override void _Ready() { animPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); rayCast = GetNode <RayCast>("RayCast"); animPlayer.Play("walk"); AddToGroup("zombies"); }
void Start() { inputManager = GameObject.Find("InputManager").GetComponent <InputManager>(); rayCast = GameObject.Find("PointerController").GetComponent <RayCast>(); dragFurniture = GameObject.Find("EditionHandler").GetComponent <DragFurniture>(); }
public static bool Check(FixedVector2 origin, FixedVector2 end, out FixedVector2 intersection, int id, Mask check, out int otherID) { _allColliders = Contexts.sharedInstance.logic.GetGroup(LogicMatcher.Collider); intersection = FixedVector2.NAN; otherID = -1; foreach (LogicEntity e in _allColliders) { if (!check.HasFlag(e.collider.value.mask)) { continue; } if (id == e.id.value) { continue; } if (RayCast.CheckIntersection(origin, end, out intersection, e.collider.value)) { otherID = e.id.value; return(true); } } return(false); }
//Set references public override void _Ready() { Input.SetMouseMode(Input.MouseMode.Captured); camera_ = GetNode <Camera>("Head/Camera"); head_ = GetNode <Spatial>("Head"); Floor_cast = GetNode <RayCast>("RayCast"); }
public override void _PhysicsProcess(float Delta) { Items.Instance Item = Game.PossessedPlayer.Inventory[Game.PossessedPlayer.InventorySlot]; if (Item != null && Item.Type != CurrentMeshType) //null means no item in slot { GhostMesh.Mesh = Meshes[Item.Type]; CurrentMeshType = Item.Type; } GhostMesh.Translation = OldPositions[0]; GhostMesh.RotationDegrees = OldRotations[0]; GhostMesh.Visible = OldVisible[0]; Player Plr = Game.PossessedPlayer; OldVisible.RemoveAt(0); OldVisible.Add(false); if (Plr.Inventory[Plr.InventorySlot] != null) { RayCast BuildRayCast = Plr.GetNode("SteelCamera/RayCast") as RayCast; if (BuildRayCast.IsColliding()) { Structure Hit = BuildRayCast.GetCollider() as Structure; if (Hit != null) { System.Nullable <Vector3> GhostPosition = BuildPositions.Calculate(Hit, Plr.Inventory[Plr.InventorySlot].Type); if (GhostPosition != null) { Vector3 GhostRotation = BuildRotations.Calculate(Hit, Plr.Inventory[Plr.InventorySlot].Type); Translation = (Vector3)GhostPosition; RotationDegrees = GhostRotation; OldVisible[1] = true; } } } } if (OldVisible[1] == false) { OldVisible[0] = false; GhostMesh.Visible = false; } OldCanBuild.RemoveAt(0); if (GetOverlappingBodies().Count > 0) { GhostMesh.MaterialOverride = RedMat; OldCanBuild.Add(false); } else { GhostMesh.MaterialOverride = GreenMat; OldCanBuild.Add(true); } CanBuild = OldCanBuild[0]; OldPositions.RemoveAt(0); OldPositions.Add(Translation); OldRotations.RemoveAt(0); OldRotations.Add(RotationDegrees); }
protected virtual void HandleProjectile(Spatial projectile) { IProjectile iProjectile = projectiles[projectile]; if (iProjectile.IsAlive()) { AttackData attackData = iProjectile.GetAttackData(); Vector3 b = -projectile.Transform.basis.GetAxis(2); projectile.Translation += b * attackData.deltaTime * 5; rayCast = projectile.GetNodeInChildrenByType <RayCast>(); if (rayCast != null && rayCast.IsColliding()) { if (!(attackData.target is IDamageReceiver)) { Node collider = rayCast.GetCollider() as Node; if (collider is IDamageReceiver) { attackData.target = collider; } } base.ProcessAttack(attackData); } } else { iProjectile.Deactivate(); projectiles.Remove(projectile); pooledProjectiles.Enqueue(projectile); } }
public float _airControl = 0.3f; // How precise air control is public override void _Ready() { _head = (Spatial)GetNode("Head"); _world = GetNode("/root/Initial/World") as World; _stairCatcher = (RayCast)GetNode("StairCatcher"); _mesh = GetNode("MeshInstance") as MeshInstance; }
public void RecalculateDynamics() { if (!GameUtils.IsPlayerValid(Player)) { return; } _screenPosition = GameUtils.WorldPointToScreenPoint(Player.Transform.position); if (Player.PlayerBones != null) { _headScreenPosition = GameUtils.WorldPointToScreenPoint(Player.PlayerBones.Head.position); } if ((Player.Profile != null) && (Player.Profile.Info != null)) { IsAI = (Player.Profile.Info.RegistrationDate <= 0); } IsOnScreen = GameUtils.IsScreenPointVisible(_screenPosition); Distance = Vector3.Distance(Main.Camera.transform.position, Player.Transform.position); IsVisible = RayCast.IsVisible(Player); TeamMate = IsInYourGroup(Player); Value = CalculateValue(Player); DistanceFromCenter = Vector2.Distance(Main.Camera.WorldToScreenPoint(Player.PlayerBones.Head.position), GameUtils.ScreenCenter); _playerColor = GetPlayerColor(Player); }
public override void _Ready() { aimTarget = GetNode <AimTarget>("AimTarget"); if (aimTarget == null) { GD.PushError("AimTarget reference not found!"); } aimRay = GetNode <RayCast>("InterpolatedCamera/AimRay"); if (aimRay == null) { GD.PushError("AimRay reference not found!"); } camera = GetNode <InterpolatedCamera>("InterpolatedCamera"); if (camera == null) { GD.PushError("InterpolatedCamera reference not found!"); } springArm = GetNode <SpringArm>("SpringArm"); if (springArm == null) { GD.PushError("SpringArm reference not found!"); } _positionStart = this.Translation; // node transformations only in Global Space SetAsToplevel(true); WaitForParentNode(); }
public override void _Ready() { GD.Print(ConfigManager.BASE_CONFIG_FILE_DIRECTORY_PATH); GD.Print(ConfigManager.BASE_DIRECTORY); GD.Print(ConfigManager.BASE_CONFIG_FILE_PATH); VisualServer.SetDebugGenerateWireframes(true); gameController = (GameController)FindParent("GameController"); ray = (RayCast)gameController.FindNode("Picker"); camera = (Camera)FindNode("Camera"); fps = (Label)camera.FindNode("FPS"); position = (Label)camera.FindNode("Position"); chunks = (Label)camera.FindNode("Chunks"); vertices = (Label)camera.FindNode("Vertices"); memory = (Label)camera.FindNode("Memory"); speed = (Label)camera.FindNode("Movement Speed"); initialRotation = new Vector3(); picker = gameController.GetPicker(); Input.SetMouseMode(Input.MouseMode.Captured); TerraVector3 origin = Converter.ConvertVector(GlobalTransform.origin); TerraBasis basis = Converter.ConvertBasis(GlobalTransform.basis); marker = new LoadMarker(origin, basis); gameController.Prepare(camera, marker); }
// 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"); } }
void Start() { rayCast = GameObject.Find("PointerController").GetComponent <RayCast>(); inputManager = GameObject.Find("InputManager").GetComponent <InputManager>(); modHandler = GameObject.Find("ModHandler").GetComponent <ModHandler>(); player = GameObject.Find("Player"); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { raycast = (RayCast)GetNode("Head/Camera/RayCast"); onGroundRaycast = (RayCast)GetNode("Head/GroundRayCast"); head = (Spatial)GetNode("Head"); bulletContainer = GetNode("Bullet Container"); bullet = ResourceLoader.Load <PackedScene>("res://Scenes/Bullet.tscn"); firingPosition = (Position3D)GetNode("Head/Gun/Firing Position"); firingTimer = (Timer)GetNode("Head/Gun/FiringTimer"); HealthLabel = (Label)GetNode("HUD/Health/Text"); AmmoLabel = (Label)GetNode("HUD/Ammo/Text"); firingSound = (AudioStreamPlayer)GetNode("Firing audio"); hitSound = (AudioStreamPlayer)GetNode("Hit audio"); addAmmoSound = (AudioStreamPlayer)GetNode("Ammo audio"); addHealthSound = (AudioStreamPlayer)GetNode("Health audio"); interactLabel = (Label)GetNode("HUD/Interact Help"); // Set life to max life Health = MaxHealth; // Set Player variable for all enemies GetTree().CallGroup("Enemies", "SetPlayer", this); // Capture mouse Input.SetMouseMode(Input.MouseMode.Captured); }
void Awake() { rayCast = GameObject.Find("Main Camera").GetComponent<RayCast>(); woodText = GameObject.Find ("Wood").GetComponent<Text> (); berriesText = GameObject.Find ("Berries").GetComponent<Text> (); rockText = GameObject.Find ("Rock").GetComponent<Text> (); }
private async Task <Entity> RemoteRayCast(Vector3 origin, Vector3 dir) { Entity entity = null; var raycast = new RayCast(origin.toRemotePos(), dir.toRemoteDir(), MaxDistance, HitCollectionPolicy.ClosestHit); var hits = await arrService.CurrentActiveSession.Actions.RayCastQueryAsync(raycast).AsTask(); if (hits != null) { foreach (var hit in hits) { var hitEntity = hit.HitEntity; if (hitEntity == null) { continue; } entity = hitEntity; break; } } return(entity); }
public override void _Ready() { GD.Randomize(); _holder = GetNode <Spatial>("Holder"); _camera = GetNode <Camera>("Holder/Camera"); _raycast = GetNode <RayCast>("Holder/ShootRaycast"); healthBar = GetNode <ProgressBar>("HUD/HealthBar"); ammoBar = GetNode <ProgressBar>("HUD/AmmoBar"); anim = GetNode <AnimationPlayer>("AnimationPlayer"); ammoTimer = GetNode <Timer>("AmmoTimer"); pistolAnim = GetNode <AnimationPlayer>("Holder/Camera/Pistol/AnimationPlayer"); wallAmountIndicator = GetNode <Label>("HUD/WallIndicator/Label"); killCountLabel = GetNode <Label>("HUD/KillCount"); coinCountIndicator = GetNode <Label>("HUD/CoinIndicator/Label"); gunAudio = GetNode <AudioStreamPlayer>("Holder/Camera/Pistol/AudioStreamPlayer"); powerupAudio = GetNode <AudioStreamPlayer>("Powerup"); afterWallTimer = GetNode <Timer>("AfterWallTimer"); Input.SetMouseMode(Input.MouseMode.Captured); }
public void PrimaryFire(float Sens) { if (Sens > 0 && !IsPrimaryFiring) { IsPrimaryFiring = true; if (Inventory[InventorySlot] != null) { //Assume for now that all primary fire opertations are to build RayCast BuildRayCast = GetNode("SteelCamera/RayCast") as RayCast; if (BuildRayCast.IsColliding()) { Structure Hit = BuildRayCast.GetCollider() as Structure; if (Hit != null && GhostInstance.CanBuild) { Vector3?PlacePosition = BuildPositions.Calculate(Hit, GhostInstance.CurrentMeshType); if (PlacePosition != null && Game.Mode.ShouldPlaceStructure(GhostInstance.CurrentMeshType, PlacePosition.Value, BuildRotations.Calculate(Hit, GhostInstance.CurrentMeshType))) { World.PlaceOn(Hit, GhostInstance.CurrentMeshType, 1); //ID 1 for now so all client own all non-default structures } } } } } if (Sens <= 0 && IsPrimaryFiring) { IsPrimaryFiring = false; } }
private static void DrawPlayerAim(GamePlayer player, Color playerColor) { Vector3 endPosition = GameUtils.WorldPointToScreenPoint(RayCast.BarrelRayCast(player.Player)); Vector3 startPosition = GameUtils.WorldPointToScreenPoint(player.Player.Fireport.position); Render.DrawLine(startPosition, endPosition, playerColor, 0.5f, true); }
void Start() { rayCast = GameObject.Find("PointerController").GetComponent <RayCast>(); inputManager = GameObject.Find("InputManager").GetComponent <InputManager>(); canClick = true; }
void Start() { btn = GetComponent <Button>(); assistantAudioSource = GameObject.Find("Assistant").GetComponent <AudioSource>(); rayCastScript = Camera.main.GetComponent <RayCast>(); }
public override void _Ready() { wall = GD.Load <PackedScene>("res://Scenes/DeployableWall.tscn"); player = (Player)GetParent().Owner; raycast = (RayCast)GetParent(); SetAsToplevel(true); Translation = raycast.GetCollisionPoint(); }
void Awake() { spawnObject.SetActive(false); rc = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<RayCast>(); //rc.SqnPzl = GameObject.Find("Gear_Cliff").GetComponent<SequencePuzzle>(); gear1 = GameObject.Find("Gear01"); gear2 = GameObject.Find("Gear02"); gear3 = GameObject.Find("Gear03"); gear4 = GameObject.Find("Gear04"); gear5 = GameObject.Find("Gear05"); // 3 points for 1st lane top1 = GameObject.Find("Trigger 1 - Top"); mid1 = GameObject.Find("Trigger 1 - Middle"); bot1 = GameObject.Find("Trigger 1 - Bottom"); // 3 points for 2nd lane top2 = GameObject.Find("Trigger 2 - Top"); mid2 = GameObject.Find("Trigger 2 - Middle"); bot2 = GameObject.Find("Trigger 2 - Bottom"); // 3 points for 3rd lane top3 = GameObject.Find("Trigger 3 - Top"); mid3 = GameObject.Find("Trigger 3 - Middle"); bot3 = GameObject.Find("Trigger 3 - Bottom"); // 3 points for 4th lane top4 = GameObject.Find("Trigger 4 - Top"); mid4 = GameObject.Find("Trigger 4 - Middle"); bot4 = GameObject.Find("Trigger 4 - Bottom"); // 3 points for 5th lane top5 = GameObject.Find("Trigger 5 - Top"); mid5 = GameObject.Find("Trigger 5 - Middle"); bot5 = GameObject.Find("Trigger 5 - Bottom"); gear1.transform.position = bot1.transform.position; gear2.transform.position = bot2.transform.position; gear3.transform.position = mid3.transform.position; gear4.transform.position = mid4.transform.position; gear5.transform.position = bot5.transform.position; }
void Start() { rc = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<RayCast>(); }