- Home /
Player jump but in reference to a middle point of a circle
I'm creating a script that the player will be able to move in a circle and dodge objects, but the player also will need to jump. The major issue is that the center point for the jump would be towards the middle of the circle since the player will always be spinning in a circle. So this is how I need to create the jump. I have the character movement already created as seen below.
void circularMove() { //The angle the player is at is equal to the speed of the player divided by radius times time in the game and the addition of the left right keys
playerAngle += Input.GetAxis("Horizontal") * Time.deltaTime * (playerSpeed / radius); // multiply all this with some speed variable (* speed);
//This is the movement on the x axis
float x = Mathf.Cos(playerAngle) * radius;
//this is the movement on the y axis
float y = Mathf.Sin(playerAngle) * radius + 3;
//the player does not move forward at this time
float z = 0;
//move the player in the direction that they clicked
transform.position = new Vector3((x - 0.04f), (y + 2.37f), (z - .56f));
}
Comment