}//update private void Move() { var absVelX = Mathf.Abs(body2D.velocity.x); var absVelY = Mathf.Abs(body2D.velocity.y); standing = (absVelY < 0.2); float forceX = 0f; float forceY = 0f; if (playerController.GetMove().x != 0) { if (absVelX < maxValues.x) { forceX = (standing ? speed : speed * airSpeedMultiplayer) * playerController.GetMove().x; sr.flipX = playerController.GetMove().x < 1; anim.SetInteger("AnimState", 1); } } else { anim.SetInteger("AnimState", 0); } if (playerController.GetMove().y != 0) { if (absVelY < maxValues.y) { forceY = jetSpeed * playerController.GetMove().y; anim.SetInteger("AnimState", 2); } } else if ((absVelY > 0 && !standing)) { anim.SetInteger("AnimState", 3); } Debug.Log("ForceX = " + forceX); body2D.AddForce(new Vector2(forceX, forceY)); }
// Update is called once per frame void Update() { future = pcs.GetFuture(); currentRoom = pcs.GetRoom(); if (!future) { destination = pastAnchors[currentRoom].transform; } else if (future) { destination = futureAnchors[currentRoom].transform; } if (pcs.canMove) { MoveToAnchor(currentRoom); } if (lastKnownRoom != currentRoom) { float d = destination.transform.position.x - this.transform.position.x; if (pcs.GetMove()) { } else { if (d > .01) { this.transform.Translate(8 * Time.deltaTime, 0.0f, 0.0f, Space.World); } else { lastKnownRoom = currentRoom; pcs.SetMove(true); } } } //Debug.Log("Future is " + future); //Debug.Log(pastAnchors[currentRoom].gameObject.transform); }