Character stops jumping after entering new "ground" platform
Hey guys, my character jumps just fine, until he moves onto a new ground platform which is directly connected to the original one, then he stops jumping all together, regardless if I go back to the old ground platform.
Here is my movement script
using UnityEngine;
public class PlayerMovement : MonoBehaviour { public Rigidbody rb; public float MoveSpeed; public float UpSpeed; public float shiftSpeed; public float stamina; bool grounded = true; bool running = false; // Update is called once per frame public void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Ground")) { grounded = true; } if (collision.gameObject.CompareTag("PlatformMoving")) { grounded = true; }
}
public void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Ground")) { grounded = false; }
if (collision.gameObject.CompareTag("PlatformMoving")) { grounded = false; }
}
void FixedUpdate() //for updating physics
{
Physics.gravity = new Vector3(0, -150f, 0);
if (Input.GetKey("w"))
{
rb.AddForce(0, 0, MoveSpeed * Time.deltaTime, ForceMode.VelocityChange);
}
if (Input.GetKey("s"))
{
rb.AddForce(0, 0, -MoveSpeed * Time.deltaTime, ForceMode.VelocityChange);
}
if (Input.GetKey("a"))
{
rb.AddForce(-MoveSpeed / 59, 0, 0 * Time.deltaTime, ForceMode.VelocityChange);
}
if (Input.GetKey("d"))
{
rb.AddForce(MoveSpeed / 59, 0, 0 * Time.deltaTime, ForceMode.VelocityChange);
}
if (rb.position.y < -5f)
{
FindObjectOfType<EndGame>().gameover();
}
if (Input.GetKeyDown ("left shift"))
{
MoveSpeed = shiftSpeed;
running = true;
}
if (Input.GetKeyUp("left shift"))
{
MoveSpeed = 110f;
running = false;
}
if (running == false && stamina < 8f) { stamina = stamina + 2 * Time.deltaTime; }
if (running == true && stamina > 0f ) { stamina = stamina - 6 * Time.deltaTime; }
if (stamina < 1f) { MoveSpeed = 110f; }
if (stamina != 8f) { shiftSpeed = MoveSpeed; }
if (stamina >= 1f) { shiftSpeed = 155f; }
}
public void Update()
{
Physics.gravity = new Vector3(0, -150f, 0);
if (Input.GetKeyDown("space") && grounded)
{
rb.AddForce(0, UpSpeed, 0 * Time.deltaTime, ForceMode.VelocityChange);
}
//placed here as sometimes not firing in fixedupdate }*
In the picture I've attached, both ground objects are tagged under ground, so I don't see why jump should stop activating (let alone stop permanently once I enter this new ground platform.)
There are other ground platforms and moving platforms, and I've not had any issues with those.
NOTE: Just checked now that If I jump between the first and second ground platforms, I can still jump. But If I move my character normally between the platforms, that's when jumping stops all together.
Any ideas how to fix this? As I'd like both platforms to be touching and looking like one whole platform.
Thanks in advance!

Your answer
Follow this Question
Related Questions
Able to jump in air? (Reward) 1 Answer
Player wont jump when platform's layer is changed to a created one! 1 Answer
Collider2D of game object does not work, unless I duplicate the game object. 1 Answer
How to make enemy jumping when detecting platform above him 0 Answers
Problem with Jumping code in Unity 2D,problem with Jumping code in Unity 2D 0 Answers