public override void Start() { base.Start(); this._controller = this.GetComponent <RigidBodyController>(); InvokeRepeating("execute", 0, _delta); rigidbody.sleepVelocity = 0f; }
/* NavMeshProvider() function is for leading player to an assigned destination. this destination * parameter is passed by the one who call this function. a position(not direction) is requaired in this function. * by now, it is not calling locomote function in order to make movement going the right way. */ //void NavMeshProvider(Vector3 destination) //{ // // agent.velocity = locomotionCtl.controller.velocity; // agent.SetDestination(destination); // this.transform.position += Vector3.Normalize(agent.steeringTarget - this.transform.position) * 0.1f; // // locomotionCtl.Locomote(Vector3.Normalize(agent.steeringTarget - this.transform.position), false); //} /* FixedUpdate() function is for standalone testing navmesh function. Push down mouse left button to set * up a destination for navmesh agent. if you want to test, uncomment * "locomotionCtl.Locomote(Vector3.Normalize(agent.steeringTarget - this.transform.position), false)" * and comment the line blew. by now, it is not calling locomote function in order to make movement * going the right way. */ private void Start() { locomotionCtl = GetComponent <RigidBodyController>(); rigidb = GetComponent <Rigidbody>(); agent.SetDestination(agent.transform.position); destination = agent.transform.position; }
public Joint(RigidBodyController A, RigidBodyController B, Type t, Point pt) { controllerA = A; controllerB = B; type = t; connectingPoint = pt; }
public PivotController(RigidBodyController body, Pivot pivot) { this.body = body; this.pivot = pivot; body.addPivot(pivot); }
void OnBodyCollisionStay(RigidBodyController controller, Collision col) { //Debug.Log("hi"); foreach (ContactPoint cp in col.contacts) { if (cp.otherCollider.gameObject.tag == "Harm") { Hurt(cp.normal, false); } /*else if(cp.otherCollider.gameObject == bomb) { * //pick up bomb again * //can't if we are hurt, bomb dropped at goal, currently animating for some reason. * if(!mPlayer.isGoal * && (mBodySpriteCtrl.anim.CurrentClip == null || mBodySpriteCtrl.anim.CurrentClip.name != "hurt") * && !attachAnimator.isPlaying * && bombGrabber.grabState == BombGrabber.GrabState.RetractBomb) { * BombActive(); * } * }*/ } //check to see if we are squashed... //if(mBody.CheckPenetrate(bodyPenetrateOfs, bodyPenetrateCheckMask)) { //die //mPlayer.GameOver(); //} }
void Awake() { if (!target) { target = GetComponent <RigidBodyController>(); } }
public void Deactivate() { EventListener.OnPlayerSpawn -= RunCommand; RigidBodyController rigidbody = VarHelper.PlayerObj.GetComponent <RigidBodyController>(); rigidbody.SetCustomVelocity(1); isActive = false; }
private void Start() { agent = this.GetComponent <NavMeshAgent>(); locomotionCtl = GetComponent <RigidBodyController>(); rigidb = GetComponent <Rigidbody>(); agent.Warp(this.transform.position); //agent.SetDestination(agent.transform.position); destination = agent.transform.position; }
public List <string> weightedConnections() { Node[] nodes = this._node.connections; List <string> result = new List <string>(); foreach (Node node in this) { result.Add("[" + node.GetNodeIndex() + "," + RigidBodyController.connectionCost((Vector3)this._node.position, (Vector3)node.position) + "]"); } return(result); }
void OnRigidbodyCollisionEnter(RigidBodyController controller, Collision col) { if (col.collider.CompareTag("DropDamage")) { RigidBodyController.CollideInfo inf = controller.GetCollideInfo(col.collider); //Debug.Log("infflag: "+inf.flag); if (inf != null && (inf.flag & CollisionFlags.Above) != CollisionFlags.None && col.relativeVelocity.sqrMagnitude >= 100.0f) { Damage dmg = col.gameObject.GetComponent <Damage>(); if (dmg) { dmg.CallDamageTo(gameObject, col.contacts[0].point, col.contacts[0].normal); } } } }
private void RunCommand(bool isRespawn) { if (!isActive) { return; } if (isRespawn) { return; } RigidBodyController rigidbody = VarHelper.PlayerObj.GetComponent <RigidBodyController>(); rigidbody.SetCustomVelocity(multiplier); DebugManager.LogToFile("[Cheat] Ittle's speed set to " + multiplier); }
void OnBodyTriggerEnter(RigidBodyController ctrl, Collider col) { if (col.gameObject.CompareTag("Star")) { mPlayer.CollectStar(col); } else if (col.gameObject.CompareTag("Enemy")) { Vector3 playerPos = mBody.transform.position; Vector3 enemyPos = col.bounds.center; Vector3 dPos = playerPos - enemyPos; //check if enemy is at bottom Vector3 localDPos = mBody.transform.worldToLocalMatrix.MultiplyVector(dPos); bool isTop = Vector3.Angle(localDPos, Vector3.up) <= 55.0f; Enemy enemy = M8.Util.GetComponentUpwards <Enemy>(col.transform, true); if (enemy) { //Debug.Log("is top: " + isTop); //kill enemy and have a free jump if (isTop && enemy.playerJumpKill) { if (enemy.FSM) { enemy.FSM.SendEvent(EntityEvent.Hit); } Vector3 localVel = mBody.localVelocity; localVel.y = enemyJumpSpeed; mBody.rigidbody.velocity = mBody.transform.rotation * localVel; mBody.jumpCounterCurrent = 1; } else if (!mPlayer.isBlinking) { Vector2 dir = dPos.normalized; Hurt(dir, false); if (enemy.state == (int)Enemy.State.Normal && enemy.FSM) { enemy.FSM.SendEvent(EntityEvent.Contact); } } } } else if (col.gameObject.CompareTag("Harm") || col.gameObject.CompareTag("Goal")) //Goal is the big monster thing { if (!mPlayer.isBlinking) { Vector2 dir = (mBody.transform.position - col.bounds.center).normalized; Hurt(dir, false); } } else if (col.gameObject.CompareTag("Death")) { mPlayer.GameOver(); } else if (col.gameObject.CompareTag("TriggerSave")) { TriggerCheckpoint triggerCP = col.GetComponent <TriggerCheckpoint>(); if (triggerCP) { mPlayer.AddTriggerCheckpoint(triggerCP); } } }
//player actions private void PlayerActions() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); RigidBodyController controller = GetComponentInParent <RigidBodyController>(); controller.Locomote(new Vector3(horizontal, 0, vertical)); controller.Rotate(); if (Input.GetKeyDown(KeyCode.Space)) { controller.Jump(); } // KeyCode for Marie-Eve and Audrey's milestone // if (Input.GetKeyDown(KeyCode.M)) // { // if(actionShield.collectedShield()) { // if (!shieldActivated){ // shieldActivated = true; // actionPickup.dropIt(); // } else { // shieldActivated = false; // } // } else return; // // } if (Input.GetMouseButtonDown(0)) { //become other player on left click CreateRay(); } if (Input.GetKeyDown(KeyCode.C)) { if (CamMode == 1) { CamMode = 0; } else { CamMode++; } StartCoroutine(CamChange()); } // if (Input.GetKeyDown(KeyCode.U)) // { // if (actionPickup && actionPickup.IsHoldingObject()) // { // Usable usable = actionPickup.HeldObject().GetComponent<Usable>(); // if (usable) // { // usable.Use(); // } // } // } if (Input.GetKeyDown(KeyCode.P)) { // if (!actionEat.isSmall()) { //call pickup function if (!actionShield.shieldIsOn()) { actionPickup.PickUp(); } //} } // // if (Input.GetKeyDown(KeyCode.F)) // { // // if(actionPickup.IsHoldingKey()) { // open.openDoor(); // } // // } if (Input.GetKeyDown(KeyCode.E)) { //call eat function actionEat.EatFood(); } // if (Input.GetKeyDown(KeyCode.T)) // { // if (actionPickup.IsHoldingObject()) // { // print("throw"); // actionThrow.ThrowObject(); // } // } //... more actions }
//player actions private void PlayerActions() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); RigidBodyController controller = GetComponentInParent <RigidBodyController>(); controller.Locomote(new Vector3(horizontal, 0, vertical)); controller.Rotate(); if (Input.GetKeyDown(KeyCode.Space)) { controller.Jump(); } if (Input.GetMouseButtonDown(0)) { //become other player on left click CreateRay(); } if (Input.GetKeyDown(KeyCode.C)) { if (CamMode == 1) { CamMode = 0; } else { CamMode++; } StartCoroutine(CamChange()); } if (Input.GetKeyDown(KeyCode.U)) { if (actionPickup && actionPickup.IsHoldingObject()) { Usable usable = actionPickup.HeldObject().GetComponent <Usable>(); if (usable) { usable.Use(); } } } if (Input.GetKeyDown(KeyCode.I)) { //call spawn function } if (Input.GetKeyDown(KeyCode.P)) { //call pickup function actionPickup = GetComponentInParent <Pickupper2>(); actionPickup.PickUp(); } if (Input.GetKeyDown(KeyCode.E)) { //call eat function actionEat = GetComponentInParent <Eat>(); actionEat.EatFood(); } if (Input.GetKeyDown(KeyCode.T)) { if (actionPickup && actionThrow && actionPickup.IsHoldingObject()) { actionThrow.ThrowObject(); } } //... more actions }
/// Use this for initialization void Start() { animator = GetComponent<Animator>(); normal = Vector3.up; gameObject.AddComponent("RigidBodyController"); controller = GetComponent<RigidBodyController>(); }
//player actions private void PlayerActions() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); RigidBodyController controller = GetComponentInParent <RigidBodyController>(); controller.Locomote(new Vector3(horizontal, 0, vertical)); controller.Rotate(); if (Input.GetKeyDown(KeyCode.Space)) { controller.Jump(); } if (Input.GetMouseButtonDown(0)) { //become other player on left click CreateRay(); } if (Input.GetKeyDown(KeyCode.C)) { if (CamMode == 1) { CamMode = 0; } else { CamMode++; } StartCoroutine(CamChange()); } if (Input.GetKeyDown(KeyCode.U)) { if (actionPickup && actionPickup.IsHoldingObject()) { Usable usable = actionPickup.HeldObject().GetComponent <Usable>(); if (usable) { usable.Use(); } } } if (Input.GetKeyDown(KeyCode.I)) { //checks for the actionpickup script and if it is holding an object if (actionPickup && actionPickup.IsHoldingObject()) { //check if the picked up item has a spawner script //get the spawner script in the children component of pickupper script actionSpawn = actionPickup.GetComponentInChildren <Spawner>(); //call spawn function actionSpawn.Spawn(); } } if (Input.GetKeyDown(KeyCode.P)) { //call pickup function actionPickup = GetComponentInParent <Pickupper>(); actionPickup.PickUp(); } if (Input.GetKeyDown(KeyCode.L)) { dropItem = GetComponentInParent <DropItem>(); dropItem.DropHeldObject(); } if (Input.GetKeyDown(KeyCode.E)) { //call eat function actionEat = GetComponentInParent <Eat>(); actionEat.EatFood(); } if (Input.GetKeyDown(KeyCode.T)) { /* * actionThrow = GetComponentInParent<Throw>(); * actionThrow.ThrowObject(); */ } //... more actions }
void OnRigidbodyCollisionEnter(RigidBodyController controller, Collision col) { if(col.collider.CompareTag("DropDamage")) { RigidBodyController.CollideInfo inf = controller.GetCollideInfo(col.collider); //Debug.Log("infflag: "+inf.flag); if(inf != null && (inf.flag & CollisionFlags.Above) != CollisionFlags.None && col.relativeVelocity.sqrMagnitude >= 100.0f) { Damage dmg = col.gameObject.GetComponent<Damage>(); if(dmg) { dmg.CallDamageTo(gameObject, col.contacts[0].point, col.contacts[0].normal); } } } }