public void Start() { unit = transform.GetComponent <Unit>(); lookAround = this.transform.Find("Vision").GetComponent <LookAround>(); visionScript = this.transform.Find("Vision").GetComponent <FieldOfView>(); hearingScript = this.transform.Find("Hearing").GetComponent <FieldOfView>(); fireArmCollider = this.transform.Find("FireArm").Find("HitCollider").gameObject; fireArmCollider.SetActive(false); PatrolStateAction(); Debug.Log("look around get : " + lookAround); }
protected override void RenderContent(UnityEngine.Object undoRecordObject) { MoveForward.RenderEditorGUI(undoRecordObject); MoveBack.RenderEditorGUI(undoRecordObject); StrafeLeft.RenderEditorGUI(undoRecordObject); StrafeRight.RenderEditorGUI(undoRecordObject); MoveUp.RenderEditorGUI(undoRecordObject); MoveDown.RenderEditorGUI(undoRecordObject); Pan.RenderEditorGUI(undoRecordObject); LookAround.RenderEditorGUI(undoRecordObject); Orbit.RenderEditorGUI(undoRecordObject); }
private void Start() { show = false; // Starts the timer automatically timerIsRunning = true; control = this.GetComponent <LookAround>(); sc = GameObject.FindGameObjectWithTag("SC").GetComponent <SceneController>(); Scene currentScene = SceneManager.GetActiveScene(); buildIndex = currentScene.buildIndex; Time.timeScale = 1; }
// camera rotation effect on turning private void Awake() { // get reference Controls = new Input_Default(); playerController = Player.GetComponent <MechPlayerController>(); grapple = Player.GetComponent <Grapple>(); // get input Controls.Player.Throttle.performed += Throttle => throttle = (Throttle.ReadValue <float>()); Controls.Player.LookAround.performed += LookAround => lookAround = (LookAround.ReadValue <Vector2>()); Controls.Player.Grapple.performed += grapplectx => grapple.StartGrapple(); Controls.Player.Grapple.canceled += grapplectx => grapple.CancleGrapple(); Controls.Player.jump.performed += jump => playerController.Jump(); }
// Start is called before the first frame update void Start() { Random.InitState(GameStarter.seed); foreach (Transform t in transform) { if (t.name == "Background") { background = t; } } stars = new GameObject[starCountTouchable]; backgroundStars = new List <GameObject>(); // First star in the centre of the universe GameObject star = Instantiate(starPrefab, new Vector3(), new Quaternion()); stars[0] = star; for (int i = 1; i < starCountTouchable; i++) { SpawnStar(i); } for (int i = 0; i < starCountTouchable * backgroundStarMultiplier; i++) { SpawnBackgroundStar(); } for (int i = 0; i < pathCount; i++) { Star start = stars[Random.Range(0, starCountTouchable - 1)].GetComponent <Star>(); Star end = stars[Random.Range(0, starCountTouchable - 1)].GetComponent <Star>(); if (start == end) { continue; } SpawnPath(start, end); } lr = FindObjectOfType <LookAround>(); if (!lr) { return; } lr.GoToStar(stars[0]); stars[0].GetComponent <Star>().SetAsStarter(); si = FindObjectOfType <SystemInfo>(); shipping = TradeItem.NONE; }
public void ForceCat() { //remove the camera movement LookAround cameraMovement = GetCameraScript(); cameraMovement.transform.eulerAngles = new Vector3(10, -80f, 0f); cameraMovement.canMove = false; //set the roation Thread.Sleep(5000); cameraMovement.canMove = true; }
private void CheckLookAround() { if (this.mLookAroundX == -1.0 && this.mLookAroundY == -1.0) { this.mLookAround = (LookAround)null; } else { if (this.mLookAround != null) { return; } this.mLookAround = new LookAround(this); } }
private void Awake() { // get reference Controls = new DefaultControls(); playerControllerScript = Player.GetComponent <playerController>(); // get input Controls.Player.move.performed += moveDirection => move = (moveDirection.ReadValue <Vector2>()); Controls.Player.LookAround.performed += LookAround => lookAround = (LookAround.ReadValue <Vector2>()); Controls.Player.flipGravityPlayer.performed += flipGravity => gravityFlipDirection = (flipGravity.ReadValue <Vector2>()); Application.targetFrameRate = SetFPS; //TEMP Controls.Player.TEMPcameratoggle.performed += TEMPCam => TEMPcam = (TEMPCam.ReadValue <float>()); }
void Start() { health = maxhealth; disable = this.GetComponent <LookAround>(); death = this.GetComponent <AudioSource>(); playingdeath = false; alive = true; ui = this.GetComponent <PlayerUI>(); jcount = maxjumps; rb = GetComponent <Rigidbody>(); rb.freezeRotation = true; sc = GameObject.FindGameObjectWithTag("SC").GetComponent <SceneController>(); ui.SetMaxHealth(maxhealth); // playerGravity = rb.gravity; }
void Start() { GameObject textObject = GameObject.Find("speed"); if(textObject != null){ speedCanvasText = textObject.GetComponent<Text>(); } textObject = GameObject.Find("distance"); if(textObject != null){ distanceCanvasText = textObject.GetComponent<Text>(); } lookAround = Camera.main.gameObject.transform.parent.GetComponent<LookAround>(); }
void Start() { GameObject textObject = GameObject.Find("speed"); if (textObject != null) { speedCanvasText = textObject.GetComponent <Text>(); } textObject = GameObject.Find("distance"); if (textObject != null) { distanceCanvasText = textObject.GetComponent <Text>(); } lookAround = Camera.main.gameObject.transform.parent.GetComponent <LookAround>(); }
public override void InitBehaviours(AiBehaviourController controller) { var stateMachine = controller.stateMachine; var inputHolder = controller.GetComponentInParent <InputHolder>(); var transform = controller.transform; FocusPriority priorityFocus = controller.focusPriority; AttentionMode enemyAttention = AiBehaviourPackUtility.GetAttentionEnemy(controller); var tExecute = new Timer(); var lookAroundMethod = new LookAround(new RangedFloat(0.5f, 0.8f), new RangedFloat(25, 50)); // TODO if seeker is not defined create MoveToDestination instead var moveToDestination = new MoveToDestinationNavigation(controller.GetComponent <Seeker>()); var velocityAccumulator = new VelocityAccumulator(0.89f, 0.125f); var destination = controller.InitBlackboardValue <Vector2>("destination"); //////////////// /// idle var lookAtTarget = enemyAttention.AddNewState(true) .AddOnBegin(inputHolder.ResetInput) .AddOnBegin(() => tExecute.RestartRandom(1f, 2f)) .AddOnUpdate(() => { velocityAccumulator.Update(transform, priorityFocus.currentFocus.GetTarget(), 0.01225f); inputHolder.rotationInput = velocityAccumulator.position - (Vector2)transform.position; inputHolder.directionInput = velocityAccumulator.position - (Vector2)transform.position; }) .AddShallReturn(() => tExecute.IsReady()) .SetUtility(() => 10) ; var lookAround = enemyAttention.AddNewState(true) .AddOnBegin(() => lookAroundMethod.Begin(transform)) .AddOnBegin(inputHolder.ResetInput) .AddOnBegin(() => tExecute.RestartRandom(0.6f, 1.5f)) .AddOnUpdate(() => { velocityAccumulator.Update(transform, priorityFocus.currentFocus.GetTarget(), 0.01225f); Vector2 targetPosition = velocityAccumulator.position - (Vector2)transform.position; float angle = Vector2.SignedAngle(Vector2.up, targetPosition); inputHolder.rotationInput = lookAroundMethod.GetRotationInput(transform, angle, 0.1f); inputHolder.directionInput = velocityAccumulator.position - (Vector2)transform.position; }) .AddShallReturn(() => tExecute.IsReady() || priorityFocus.currentFocus.GetTarget().velocity.sqrMagnitude > 20) .SetUtility(() => 15f - 0.225f * priorityFocus.currentFocus.GetTarget().velocity.sqrMagnitude) ; /// ideas: /// looks a little bit to sides sometimes /// tries to keep certain distance from enemy /// Input Accumulation (aka velocity ?) /*/// lookAround * var lookAround = enemyAttention.AddNewState(true) * .AddOnBegin(() => lookAroundMethod.Begin(transform)) * .AddOnBegin(inputHolder.ResetInput) * .AddOnBegin(() => tExecute.RestartRandom(0.25f, 0.4f)) * .AddOnUpdate(() => * { * inputHolder.rotationInput = lookAroundMethod.GetRotationInput(transform); * }) * .AddShallReturn(() => tExecute.IsReady()) * .SetUtility(6) * ; * * /// randomMovement * var randomMovement = enemyAttention.AddNewState(true) * .AddOnBegin(() => moveToDestination.SetDestination_Search(priorityFocus, 20)) * .AddOnBegin(inputHolder.ResetInput) * .AddOnBegin(() => tExecute.RestartRandom(0.75f, 1.5f)) * .AddOnUpdate(() => * { * inputHolder.positionInput = moveToDestination.ToDestination(); * //inputHolder.positionInput = Vector2.Lerp(inputHolder.positionInput, moveToDestination.ToDestination(), 0.985f ); * }) * .AddShallReturn(() => tExecute.IsReady()) * .SetUtility(2f) * ;*/ }
public override void InitBehaviours(AiBehaviourController controller) { var stateMachine = controller.stateMachine; var inputHolder = controller.GetComponentInParent <InputHolder>(); var transform = controller.transform; FocusPriority priorityFocus = controller.focusPriority; AttentionMode painAttention = AiBehaviourPackUtility.GetAttentionPain(controller); var tExecute = new Timer(); var lookAroundMethod = new LookAround(new RangedFloat(0.5f, 0.8f), new RangedFloat(25, 50)); // TODO if seeker is not defined create MoveToDestination instead var moveToDestination = new MoveToDestinationNavigation(controller.GetComponent <Seeker>()); var velocityAccumulator = new VelocityAccumulator(0.89f, 0.075f); var destination = controller.InitBlackboardValue <Vector2>("destination"); //////////////// var idle = painAttention.AddNewState(true) .AddOnBegin(() => tExecute.RestartRandom(0.15f, 0.3f)) .AddOnBegin(inputHolder.ResetInput) .AddShallReturn(tExecute.IsReady) .SetUtility(0.1f); ; var moveAway = painAttention.AddNewState(true) .AddOnBegin(inputHolder.ResetInput) .AddOnBegin(() => tExecute.RestartRandom(0.25f, 0.325f)) .AddOnUpdate(() => { Vector2 toTarget = painAttention.focus.ToTarget(); inputHolder.positionInput = -toTarget; inputHolder.rotationInput = toTarget; inputHolder.directionInput = toTarget; //Debug.Log(painAttention.activeTime); }) .AddShallReturn(() => tExecute.IsReady()) .SetUtility(() => 10) .AddCanEnter(() => painAttention.activeTime < 0.1f) ; BoxValue <Vector2> initialDirection = new BoxValue <Vector2>(Vector2.zero); var hit = painAttention.AddNewState(true) .AddOnBegin(inputHolder.ResetInput) .AddOnBegin(() => tExecute.RestartRandom(1.0f, 1.5f)) .AddOnBegin(() => inputHolder.directionInput = transform.up) .AddOnUpdate(() => { Vector2 toTarget = painAttention.focus.ToTarget(); inputHolder.positionInput = tExecute.IsReady(0.2f) ? Vector2.zero : -toTarget; if (tExecute.IsReady(0.2f)) { inputHolder.directionInput = PolarVector2.MoveTowards( inputHolder.directionInput.GetPolarVector(), toTarget.GetPolarVector(), 3.5f, 0.25f); inputHolder.keys[0] = true; } //Debug.Log(painAttention.activeTime); }) .AddShallReturn(() => tExecute.IsReady()) .SetUtility(() => 15) .AddCanEnter(() => painAttention.activeTime < 0.1f) ; /// TODO: /// later (if have not switched to another event) ai will have search behaviours /// look around ( standard 360 degrees with agressive switches) /// move randomly around /// search manager (which will somehow generate points to check) /// once in a while look at random point close to the hit position }
public BTGuard(Guard ownerBrain) : base(ownerBrain) { // Actions chaseAction = new Chase(NodeOwner); investigateAction = new Investigate(NodeOwner); lookAroundAction = new LookAround(NodeOwner); moveToNextPatrolPointAction = new MoveToPatrolPoint(NodeOwner); chooseNextPatrolPointAction = new ChooseNextPatrolPoint(NodeOwner); catchSpyAction = new CatchSpy(NodeOwner); // Conditions canIHearSpyCondition = new CanIHearSpy(NodeOwner); canISeeSpyCondition = new CanISeeSpy(NodeOwner); haveIArrivedToThePatrolPointCondition = new HaveIArrivedToThePatrolPoint(NodeOwner); haveIFinishedLookingAroundCondition = new HaveIFinishedLookingAround(NodeOwner); amIChasingCondition = new AmIChasing(NodeOwner); haveIFinishedInvestigatingCondition = new HaveIFinishedInvestigating(NodeOwner); canICatchSpyCondition = new CanICatchSpy(NodeOwner); // Composites rootSequence = new Sequence(); patrolSequence = new Sequence(); patrolParallel = new Parallel(3, 1); chaseParallel = new Parallel(3, 1); chaseSequence = new PrioritisedSequence(); engageSelector = new Selector(); patrolSelector = new Selector(); investigationParallel = new Parallel(3, 1); investigationSequence = new Sequence(); hearChaseSequence = new Sequence(); seeChaseSequence = new Sequence(); // Decorators repeatUntilFailDecoratorForPatrolSequence = new RepeatUntilFail(patrolSequence); // Tree Structure // Tree level 0 rootSequence.AddChildNode(patrolSelector); rootSequence.AddChildNode(engageSelector); // Tree level 1 patrolSelector.AddChildNode(amIChasingCondition); patrolSelector.AddChildNode(patrolParallel); engageSelector.AddChildNode(chaseParallel); engageSelector.AddChildNode(investigationParallel); // Tree level 2 patrolParallel.AddChildNode(repeatUntilFailDecoratorForPatrolSequence); patrolParallel.AddChildNode(canIHearSpyCondition); patrolParallel.AddChildNode(canISeeSpyCondition); chaseParallel.AddChildNode(chaseSequence); chaseParallel.AddChildNode(hearChaseSequence); chaseParallel.AddChildNode(seeChaseSequence); investigationParallel.AddChildNode(investigationSequence); investigationParallel.AddChildNode(canIHearSpyCondition); investigationParallel.AddChildNode(canISeeSpyCondition); // Tree level 3 patrolSequence.AddChildNode(moveToNextPatrolPointAction); patrolSequence.AddChildNode(haveIArrivedToThePatrolPointCondition); patrolSequence.AddChildNode(lookAroundAction); patrolSequence.AddChildNode(haveIFinishedLookingAroundCondition); patrolSequence.AddChildNode(chooseNextPatrolPointAction); chaseSequence.AddChildNode(chaseAction); chaseSequence.AddChildNode(canICatchSpyCondition); chaseSequence.AddChildNode(catchSpyAction); hearChaseSequence.AddChildNode(canIHearSpyCondition); hearChaseSequence.AddChildNode(chaseAction); seeChaseSequence.AddChildNode(canISeeSpyCondition); seeChaseSequence.AddChildNode(chaseAction); investigationSequence.AddChildNode(investigateAction); investigationSequence.AddChildNode(haveIFinishedInvestigatingCondition); }
//private static Callback postLookBehavior; void Awake() { instance = this; animator = GetComponent <Animator> (); }
// Use this for initialization void Start() { //Assign the blackboard blackboard = blackBoardObj.GetComponent <Blackboard>(); //Create the nodes and populate the children Lists within them tree = new Selector(); //Root of the spotted sub-tree Sequence spottedSequence = new Sequence(); tree.children.Add(spottedSequence); //Player detected condition node PlayerDetected playerDetected = new PlayerDetected(); spottedSequence.children.Add(playerDetected); //Add a Succeeder repeater for the melee sub-tree SucceederRepeater succeeder = new SucceederRepeater(); spottedSequence.children.Add(succeeder); //Sequence for the melee sub-tree Sequence subSequence = new Sequence(); succeeder.child = subSequence; //Add the melee weapon check to the sequence MeleeWeapon meleeWeapon = new MeleeWeapon(); subSequence.children.Add(meleeWeapon); //Add in the persuit movement to PersuitMovement persuitMovement = new PersuitMovement(); subSequence.children.Add(persuitMovement); CheckRange checkRange = new CheckRange(); spottedSequence.children.Add(checkRange); CheckAttackCooldown checkCooldown = new CheckAttackCooldown(); spottedSequence.children.Add(checkCooldown); AttackTarget attack = new AttackTarget(); spottedSequence.children.Add(attack); //Root of the Search sub-tree Sequence searchSequence = new Sequence(); tree.children.Add(searchSequence); //Flipper FlipperRepeater flipper = new FlipperRepeater(); searchSequence.children.Add(flipper); //PlayerDetected playerDetected = new PlayerDetected(); flipper.child = playerDetected; flipper = new FlipperRepeater(); searchSequence.children.Add(flipper); //following sequence Sequence followingSequence = new Sequence(); flipper.child = followingSequence; CheckFollowing checkFollowing = new CheckFollowing(); followingSequence.children.Add(checkFollowing); persuitMovement = new PersuitMovement(); followingSequence.children.Add(persuitMovement); UpdatePlayerPos updatePlayerPos = new UpdatePlayerPos(); followingSequence.children.Add(updatePlayerPos); FollowCounter followCounter = new FollowCounter(); followingSequence.children.Add(followCounter); EnableCurious enableCurious = new EnableCurious(); followingSequence.children.Add(enableCurious); //Curious sub-tree Sequence curiousSequence = new Sequence(); searchSequence.children.Add(curiousSequence); CheckCurious checkCurious = new CheckCurious(); curiousSequence.children.Add(checkCurious); LookAround lookAround = new LookAround(); curiousSequence.children.Add(lookAround); DisableCurious disableCurious = new DisableCurious(); curiousSequence.children.Add(disableCurious); }