private void OnMoveCommand(List <Vector3> path) { InputManager.Instance.SetCurrentHandler(SelectionManager.Instance); List <ISelectable> selectedUnit = SelectionManager.Instance.CurrentSelection; foreach (ISelectable selectable in selectedUnit) { PathFollower pathFollower = selectable.GetTransform().GetComponent <PathFollower>(); if (pathFollower != null) { pathFollower.SetPath(path); } } Transform targetItem = SelectionManager.Instance.GetTargetItem(); System.Action onSelectionChange = () => { CameraController.Instance.OrbitCamera.SetTarget(targetItem); }; SelectionManager.Instance.onSelectionChange += onSelectionChange; SelectionManager.Instance.DeselectAll(); SelectionManager.Instance.onSelectionChange -= onSelectionChange; }
void Start() { BobPlayerAnimator = transform.FindChild("BobPlayer").GetComponent <Animator>(); // Set player's position GameObject startingNode = GameObject.Find( GlobalGameManager.GGM.getPlayerPositionOnMap() ); Vector3 vec = startingNode.GetComponent <Transform>().position; this.transform.position = new Vector3(vec.x, vec.y, this.transform.position.z); // Set current node to the pathfinder pathfinder = this.GetComponent <PathFollower> (); pathfinder.setParent(this.transform.gameObject); pathfinder.setCurrentNode( startingNode.GetComponent <Node> () ); // Print current position to console Debug.Log("Bobin alotusnode: " + pathfinder.getCurrentNode()); // Scale bob based on current position BobScale(); }
void OnCollisionEnter(Collision other) { if (colider) { if (other.gameObject.tag == "Player") { if (quitarpropiedadenemigo) { PathFollower path_aux = GetComponent <PathFollower>(); path_aux.desactivar_fun_enemigo(); } if (agrandar) { jugadoranim_aux.activarluz(); StartCoroutine(Ampliarluz()); } else { GameObject aux_obj = Instantiate(crearalcontactar, other.transform.position, Quaternion.identity); aux_obj.GetComponent <seguir>().asiganrobjetivo(other.gameObject); StartCoroutine(Reducirluz()); } gameObject.transform.localScale = new Vector3(0, 0, 0); gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, 20f); Collider aux = GetComponent <Collider>(); aux.isTrigger = true; } } }
private void OnTriggerEnter2D(Collider2D collision) { // if (collision.gameObject.GetComponent<NPCController>() == false && collision.gameObject!=CommonObjectsStore.player) // { // return; // } if (collision.gameObject.transform.root.GetComponent <NPCController>() == true) { if (shouldWeTeleportGameObject(collision.gameObject)) { //Debug.LogError("Teleport Collision with " + collision.transform.root.gameObject.name); PathFollower pf = collision.transform.root.GetComponent <PathFollower>(); objectsITeleported.Add(collision.gameObject); timerResetValues.Add(3.0f); collision.transform.root.position = toGoTo.transform.position; //pf.workOutPositionOnPath(); pf.getPath(pf.transform.position, pf.target.transform.position); } } else { if (shouldWeTeleportGameObject(collision.gameObject)) { if (collision.gameObject.transform.root.gameObject == CommonObjectsStore.player) { objectsITeleported.Add(collision.gameObject); timerResetValues.Add(3.0f); collision.transform.root.position = toGoTo.transform.position; } } } }
void Update() { if (Input.GetKeyDown(KeyCode.Space)) { target.isTarget = false; if (i >= carTarget.Length) { i = 0; target = carTarget[i].gameObject.GetComponent <PathFollower>(); target.isTarget = true; m_clearShot.LookAt = carTarget[i].transform; followCamera.LookAt = carTarget[i].transform; followCamera.Follow = carTarget[i].transform; } else { i++; target = carTarget[i].gameObject.GetComponent <PathFollower>(); target.isTarget = true; m_clearShot.LookAt = carTarget[i].transform; followCamera.LookAt = carTarget[i].transform; followCamera.Follow = carTarget[i].transform; } } }
public void OnTriggerExit(Collider other) { if (other.CompareTag("Car")) { carToCheck = null; //Emptys car variable so it can be reassigned and reused with another car } }
public void PullVoltagePoleTrigger(Collider other, GameObject source) { GameObject electron = other.gameObject; electron.GetComponent <Charge>().JustCreated = true; PathFollower pathFollower = electron.GetComponent <PathFollower>(); if (source == positiveVoltagePole) { electron.transform.position = negativeVoltagePole.transform.position; pathFollower.SetPath(minusCable.GetComponent <IPath>()); pathFollower.reverseOrder = true; pathFollower.followPath = true; } if (source == negativeVoltagePole) { electron.transform.position = positiveVoltagePole.transform.position; pathFollower.SetPath(plusCable.GetComponent <IPath>()); pathFollower.reverseOrder = true; pathFollower.followPath = true; } }
// Update is called once per frame void Update() { { try //try catch to destroy object if any incorrect indexing occurs (such as when deleting machines) { GameObject obj = pathList.path[currentPoint].gameObject; Vector3 moveTo = pathList.path[currentPoint].position; float dist = Vector3.Distance(moveTo, transform.position); moveTo.y += .18f; if (dist <= 1.25) //distance between two machines isn't too large { transform.position = Vector3.MoveTowards(transform.position, moveTo, speed); } if (dist == reachDist) //start moving to next machine { if (obj.CompareTag("Path")) { currentPoint++; } else if (obj.CompareTag("Zapper")) { GameObject candyChange = GameObject.Instantiate(zapperConversion, gameObject.transform.position, gameObject.transform.rotation); PathFollower cChange = candyChange.GetComponent <PathFollower>(); cChange.currentPoint = currentPoint + 1; Destroy(this.gameObject); } else if (obj.CompareTag("Conversion")) { GameObject candyChange = GameObject.Instantiate(conversionConversion, gameObject.transform.position, gameObject.transform.rotation); PathFollower cChange = candyChange.GetComponent <PathFollower>(); cChange.currentPoint = currentPoint + 1; Destroy(this.gameObject); } else if (obj.CompareTag("Taffy")) { GameObject candyChange = GameObject.Instantiate(tappyConversion, gameObject.transform.position, gameObject.transform.rotation); PathFollower cChange = candyChange.GetComponent <PathFollower>(); cChange.currentPoint = currentPoint + 1; Destroy(this.gameObject); } else { currentPoint++; } } } catch (System.Exception) { Destroy(this.gameObject); } } }
// Use this for initialization void Start() { pathFollower = transform.parent.GetComponent <PathFollower>(); pathFollower.path = paths[currentPath]; ball = GameObject.Find("DisplayBall"); CameraFade.StartAlphaFade(Color.black, true, 5); }
public void TestPath(int pathIndex) { GameObject go = GameObject.Instantiate(obstaclePrefabs[0]); PathFollower pathFollower = go.GetComponent <PathFollower>(); pathFollower.StartPath(paths[pathIndex]); }
void Start() { thisRigidBody = GetComponent <Rigidbody2D>(); pathFollower = GetComponent <PathFollower>(); thisCollider = GetComponent <Collider2D>(); thisAnimator = GetComponent <Animator>(); }
private void ComputeNextWaypoint(GameObject go, PathFollower follower, Node node) { Path path = null; if (!followersPath.TryGetValue(go, out path) || path.nodes.Count == 0 || path.nodes[path.nodes.Count - 1].Equals(node)) { if (path != null) { followersPath.Remove(go); } ComputePathTo(go, node, follower.destination); // Compute pathh to destination } followersPath.TryGetValue(go, out path); /*if (path.nodes.Count == 0 || follower.destination.Equals(follower.previousWaypoint)) * { * // No more destination * GameObjectManager.removeComponent(follower); * followersPath.Remove(go); * }*/ //else { // Set next waypoint and face it follower.nextWaypoint = path.nodes[0]; // Remove step from path path.nodes.RemoveAt(0); } }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject waypointGO in _triggeredWaypoints) { GameObject[] targets = waypointGO.GetComponent <Triggered3D>().Targets; foreach (GameObject targetGO in targets) { PathFollower follower = targetGO.GetComponent <PathFollower>(); Node current = waypointGO.GetComponent <Node>(); if (follower != null) { if (current.Equals(follower.destination)) { GameObjectManager.removeComponent(follower); followersPath.Remove(targetGO); continue; } if (follower.previousWaypoint == null || !follower.previousWaypoint.Equals(current)) { ComputeNextWaypoint(targetGO, follower, current); follower.previousWaypoint = current; } MoveToward move = targetGO.GetComponent <MoveToward>(); move.target = follower.nextWaypoint.gameObject.transform.position; } } } }
private void Awake() { instance = this; aISteering = GetComponent <AISteering>(); pathFollower = GetComponent <PathFollower>(); healthBar = transform.GetChild(3).gameObject; }
void Start() { _pathFollower = GetComponent <PathFollower>(); //StartCoroutine(StartSetup()); StartSetupAA(); }
private void HandleHitWithOtherVehicle(PathFollower follower, RaycastHit hitInfo, float distance) { if (hitInfo.distance < distance * 0.1f) { Vehicle.ForceSpeed(0); } else if (hitInfo.distance < distance * 0.5f && (follower.Acceleration <= 0 || Mathf.Approximately(follower.CurrentSpeed, 0))) { Vehicle.ForceSpeed(follower.CurrentSpeed); } else if (_vehicle.CurrentSpeed > follower.CurrentSpeed) { Vehicle.ChangeSpeed(follower.CurrentSpeed, -Vehicle.CurrentSpeed / (hitInfo.distance / Vehicle.CurrentSpeed)); } else if (hitInfo.distance > distance) { Vehicle.ChangeSpeed(Mathf.Min(follower.CurrentSpeed, Vehicle.topSpeed), Mathf.Min(follower.Acceleration, Vehicle.topSpeed)); } else if (hitInfo.distance > 0.5f) { Vehicle.ChangeSpeed(Vehicle.CurrentSpeed / 2, Vehicle.CurrentSpeed); } else { Vehicle.ForceSpeed(0); } _state = VehicleState.Tailing; }
void Start() { // 플레이어 충돌 콜라이더 값 player_collider = PlayerMove.GetComponent <Collider>(); //팅커벨 무브-알파값 tinkerBellPath = PathObject.GetComponent <PathFollower>(); renderer = Pathmodel.GetComponentsInChildren <Renderer>(); //renderer = new Renderer[]; // PointLamp_Renderer = new Renderer[PointLampModl.Length]; //팅커벨 파티클 event_TinkerBellEnter = Enter_TinkerBell.GetComponentInChildren <ParticleSystem>(); //플레이어 move playerController = GameObject.FindObjectOfType <Player_HJ>(); _animator = playerModeling.GetComponent <Animator>(); //등불 퍼즐 스크립트 coliderscript = GameObject.FindObjectOfType <ColliderMgr>(); Enter_TinkerBell.gameObject.SetActive(false); This_colider = this.gameObject.GetComponentInChildren <BoxCollider>(); // renderer.material.color = new Color(0, 0, 0, 0); }
void Start() { tm = GetComponentInChildren <TextMesh>(); gms = GameManagerScript.instance; pf = GetComponent <PathFollower>(); if (isPlayer) { isPlayer = true; GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollowScript>().SetCamera(this.transform); UIManagerScript.instance.mainPlayerStats = this.GetComponent <Statistics>(); ps = GetComponent <PlayerScript>(); GetComponent <AIScript>().enabled = false; } else { isPlayer = false; ais = GetComponent <AIScript>(); GetComponent <PlayerScript>().enabled = false; } // gms.stats.Add(this.GetComponent<Statistics>()); gms.AddToStats(GetComponent <Statistics>()); tm.text = playerName; thisTransform = GetComponent <Transform>(); startZ = thisTransform.position.z; goalZ = GameObject.FindGameObjectWithTag("Goal").GetComponent <Transform>().position.z; divZ = goalZ - startZ; }
public void UpdateState(MonsterViewModel viewModel) { if (follower == null) { follower = GetComponent <PathFollower>(); } if (attacher == null) { attacher = GetComponent <PrefabAttacher>(); attacher.AttachPrefab(); healthBar = attacher.GetInstance().GetComponent <Bar>(); healthBar.pointsImage = attacher. GetInstance(). transform.Find("Health"). GetComponent <Image>(); } healthBar.UpdateState(viewModel.Health, viewModel.MaxHealth); follower.movementSpeed = viewModel.Speed; if (viewModel.IsDead) { FlyingTextSpawner.SpawnGoldEarned(viewModel.KillReward, gameObject); Destroy(gameObject); } }
public override void Enter() { ship.StartCoroutine(IUpdate()); PathFollower pathFollower = ship.boid.GetBehaviour <PathFollower> (); Wander wanderBehaviour = ship.boid.GetBehaviour <Wander> (); Pursue pursueBehaviour = ship.boid.GetBehaviour <Pursue> (); offsetBehaviour = ship.boid.GetBehaviour <OffsetPursue> (); if (pathFollower != null) { pathFollower.enabled = false; } if (wanderBehaviour != null) { wanderBehaviour.enabled = true; wanderBehaviour.weight = 0.25f; } if (pursueBehaviour != null) { pursueBehaviour.enabled = false; } if (offsetBehaviour != null) { offsetBehaviour.leader = leaderShip.boid; offsetBehaviour.enabled = true; } }
private IEnumerator ElectronChargeEffect() { GameObject plusCable = GameObject.Find("Cable+"); GameObject minusCable = GameObject.Find("Cable-"); int numberOfElectrons = Mathf.Abs(Mathf.RoundToInt(powerVoltage - voltage)) * 2; float electronTimeInterval = 5 * seriesResistance * capacitance / numberOfElectrons; float electronSpeed = 0.01f; while (numberOfElectrons > 0 && chargeState != ChargeState.IDLE) { Charge electron = chargePoolHander.GetNewElectron(); chargesOnCable.Add(electron); PathFollower pathFollower = electron.GetComponent <PathFollower>(); pathFollower.maxSpeed = electronSpeed; if (voltage > powerVoltage) { electron.transform.position = plate1.transform.position; pathFollower.SetPath(minusCable.GetComponent <IPath>()); } else { electron.transform.position = plate2.transform.position; pathFollower.SetPath(plusCable.GetComponent <IPath>()); } numberOfElectrons--; yield return(new WaitForSecondsWithPause(electronTimeInterval)); } }
void SpawnBoss() { GameObject clone = Instantiate(enemyPrefab[1], pathWaypoints[0].transform.position, enemyPrefab[1].transform.rotation, transform); PathFollower clonePath = clone.GetComponent <PathFollower>(); clonePath.SetPath(pathWaypoints); }
private void PathManager_OnPointReached(int index, PathFollower pathFollower) { int direction = pathFollower.IncreasingOrder == true ? 1 : -1; int nodeIndex = (index + direction) % pathNodes.Count; pathFollower.SetCurrentPathNode(nodeIndex, pathNodes[nodeIndex].transform.position); }
public void initialise(Vector3Int to, Vector3Int start, PathFollower wanted) { posToGoTo = to; posFrom = start; wantedPath = wanted; finalPath = new List <ThreadedWorldTile> (); }
// Start is called before the first frame update void Start() { SubwayMovement = GameObject.Find("---StationController").GetComponent <SubwayMovement>(); AllMachines = GameObject.Find("---ClothInMachineController").GetComponent <AllMachines>(); car = GameObject.Find("SubwayMapCar"); PathFollower = car.GetComponent <PathFollower>(); //used when the timer is always on screen //zRotation = 360 / (SubwayMovement.stayTime + SubwayMovement.moveTime); myRectT = GetComponent <RectTransform>(); //SubwayMovement.Hide(bubble); myButton = GetComponent <Button>(); selfImage = GetComponent <Image>(); selfImage.enabled = false; if (!isFast && !SubwayMovement.pauseBeforeMove) { //now the timer is placed on the bag //zRotation = 360 / (3 *(SubwayMovement.stayTime + SubwayMovement.moveTime)); fillAmount = 1; selfImage.fillAmount = fillAmount; selfImage.enabled = true; } }
void OnEnable() { lWidth = EditorGUIUtility.labelWidth; pf = target as PathFollower; list = new ReorderableList(serializedObject, serializedObject.FindProperty("path"), true, true, true, true); // Tell the list how to render it's contents list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); EditorGUIUtility.labelWidth = 14f; rect.width /= 3; EditorGUI.LabelField(rect, string.Format("Point {0}", index)); rect.x += rect.width; EditorGUI.PropertyField(rect, element.FindPropertyRelative("x"), new GUIContent("X")); rect.x += rect.width; EditorGUI.PropertyField(rect, element.FindPropertyRelative("y"), new GUIContent("Y")); EditorGUIUtility.labelWidth = lWidth; }; list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Path Points"); }; list.onSelectCallback = (ReorderableList l) => { SceneView.RepaintAll(); }; labelStyle = new GUIStyle(); labelStyle.fontSize = 16; labelStyle.fontStyle = FontStyle.Bold; }
void Awake() { _playerCollisions = player.GetComponent <PlayerCollisionScript>(); if (_playerCollisions == null) { Debug.LogError("Player object is broken"); } _playerCollisions.LevelMgr = this; _pathFollower = player.GetComponent <PathFollower>(); if (_pathFollower == null) { Debug.LogError("Player object is broken"); } _playerSelector = player.GetComponent <PlayerSeletor>(); if (_playerSelector == null) { Debug.LogError("Player object is broken"); } if (checkpoints == null || checkpoints.Length == 0) { Debug.LogError("No checkpoint for level are set"); } currentCheckpoint = checkpoints[0]; DragController.instance.LevelMgr = this; }
private void Awake() { spriteRenderer = GetComponentInChildren <SpriteRenderer>(); spinner = GetComponentInChildren <SpinnyThing>(); pathFollower = GetComponent <PathFollower>(); killSound = GameObject.Find("KillSound").GetComponent <AudioSource>(); }
virtual protected void Start() { rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); pathFollower = GetComponent <PathFollower>(); gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); animatorActualSpeed = animator.speed; }
private void Awake() { ballPos = FindObjectOfType <RandomPosition>(); batter = FindObjectOfType <PathFollower>(); projectile = FindObjectOfType <Projectile>(); text.text = ""; ballPos.FindNewPosition(); }
private void Init() { masterPoint = FindObjectOfType<Master_Instance>(); master.setLayer("enemies",this.gameObject); lifebar = master.getChildFrom("Lifebar",this.gameObject); getPoint(); pathFollow = GetComponent<PathFollower>(); anim = this.gameObject.GetComponent<Animator> (); anim.SetBool ("walk", false); anim.SetBool ("dead", false); anim.SetBool ("attack", false); }
// Use this for initialization void Start() { pathFollower = GetComponent<PathFollower>(); float thetaInc = Mathf.PI * 2.0f / (float)numberOfWaypoints; for (int i = 0; i < numberOfWaypoints; i++) { float theta = thetaOffset + (thetaInc * i); Vector3 pos = new Vector3(); pos.x = transform.position.x + (Mathf.Sin(theta) * radius); pos.z = transform.position.z + (Mathf.Cos(theta) * radius); pathFollower.waypoints.Add(pos); } }
public void Init() { //Debug.Assert(_marchStartOffset - _crowdOffset > 0f); _heroPathFollower = new PathFollower(_path); _heroPathFollower.Speed = _speed; _heroPathFollower._offset = Vector3.up * 0.5f; _heroPathFollower._FollowerMove += _eventManager.OnFollowerMove; _heroPathFollower._currNodeIdx = 0; _heroPathFollower._currTngOffset = _marchStartOffset; _crowdPathFollower = new PathFollower(_path); _crowdPathFollower.Speed = _speed; _crowdPathFollower._currNodeIdx = 0; _crowdPathFollower._currTngOffset = _marchStartOffset - _crowdOffset; }
void Awake() { pf = GetComponent<PathFollower>(); lvt = GetComponent<Levitatable>(); if (PathStarts == null) { PathStarts = GameObject.FindObjectsOfType<ConveyorBeltStartNode>().Select(cbsn => cbsn.GetComponent<PathNode>()).ToArray(); } spawningObject = null; if (RespawnOnStart) { isWaitingToSpawn = true; } else { isWaitingToSpawn = false; } }
/* * Walk at range distance from mobile * * iSteps : Number of steps * bRun : Do we run * iWantDistMin : The minimum distance we want to be * iWantDistMax : The maximum distance we want to be * */ public virtual bool WalkMobileRange(Mobile m, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves) { return false; } if (m != null) { for (int i = 0; i < iSteps; i++) { // Get the curent distance int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m); if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax) { bool needCloser = (iCurrDist > iWantDistMax); bool needFurther = !needCloser; if (needCloser && m_Path != null && m_Path.Goal == m) { if (m_Path.Follow(bRun, 1)) { m_Path = null; } } else { Direction dirTo; if (iCurrDist > iWantDistMax) { dirTo = m_Mobile.GetDirectionTo(m); } else { dirTo = m.GetDirectionTo(m_Mobile); } // Add the run flag if (bRun) { dirTo = dirTo | Direction.Running; } if (!DoMove(dirTo, true) && needCloser) { m_Path = new PathFollower(m_Mobile, m); m_Path.Mover = DoMoveImpl; if (m_Path.Follow(bRun, 1)) { m_Path = null; } } else { m_Path = null; } } } else { return true; } } // Get the curent distance int iNewDist = (int)m_Mobile.GetDistanceToSqrt(m); if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax) { return true; } else { return false; } } return false; }
public virtual bool MoveTo(Mobile m, bool run, int range) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == null || m.Deleted) { return false; } if (m_Mobile.InRange(m, range)) { m_Path = null; return true; } if (m_Path != null && m_Path.Goal == m) { if (m_Path.Follow(run, 1)) { m_Path = null; return true; } } else if (!DoMove(m_Mobile.GetDirectionTo(m), true)) { m_Path = new PathFollower(m_Mobile, m); m_Path.Mover = DoMoveImpl; if (m_Path.Follow(run, 1)) { m_Path = null; return true; } } else { m_Path = null; return true; } return false; }
public virtual bool MoveTo(IPoint3D p, bool run, int range) { if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || p == null || (p is IDamageable && ((IDamageable)p).Deleted)) { return false; } if (m_Mobile.InRange(p, range)) { m_Path = null; return true; } if (m_Path != null && m_Path.Goal == p) { if (m_Path.Follow(run, 1)) { m_Path = null; return true; } } else if (!DoMove(m_Mobile.GetDirectionTo(p), true)) { m_Path = new PathFollower(m_Mobile, p); m_Path.Mover = DoMoveImpl; if (m_Path.Follow(run, 1)) { m_Path = null; return true; } } else { m_Path = null; return true; } return false; }
private void TendTo(PathFollower pathFollower, Transform transform, float speed) { Vector3 direction = transform.position - pathFollower.transform.position; Vector3 mouvement = direction.normalized * speed * Time.deltaTime; pathFollower.transform.position += mouvement; }
public virtual bool MoveTo(Mobile m, bool run, int range) { if (this.m_Mobile.Deleted || this.m_Mobile.DisallowAllMoves || m == null || m.Deleted) return false; if (this.m_Mobile.InRange(m, range)) { this.m_Path = null; return true; } if (this.m_Path != null && this.m_Path.Goal == m) { if (this.m_Path.Follow(run, 1)) { this.m_Path = null; return true; } } else if (!this.DoMove(this.m_Mobile.GetDirectionTo(m), true)) { this.m_Path = new PathFollower(this.m_Mobile, m); this.m_Path.Mover = new MoveMethod(DoMoveImpl); if (this.m_Path.Follow(run, 1)) { this.m_Path = null; return true; } } else { this.m_Path = null; return true; } return false; }