public void whileSuperSpeed()
{
m_Rigidbody2D.gravityScale = 0;
Debug.Log(superspeeddirection); //(return the angle given by the joystick)
m_Rigidbody2D.velocity = (transform.up * 100); //Get the axis pointing above the head of the player according to his rotation
if (SuperSpeedCheck.IsTouchingLayers(m_WhatIsWalls)) //if the player touches a wall, set everything back to normal
{
IsInSuperSpeedMode = false;
transform.eulerAngles = new Vector3(0, 0, 0);
}
}
So, i have this code making the character going in a given direction like a rocket. It works perfectly fine in the editor, but when i build the game, it doesn’t. Instead, it only goes up or down. If the giver direction is Top-Left, it will go top, but slower than if the direction is top. If the direction is down, it goes down. If the direction is left or right, it just stops moving and stays in the air because gravity was set to 0.
But the debug log still gives the right angle, and the player still rotate and have the right angle.
I’ve been trying addforces , addforce relative, with both of the forcemode, and the problem stays the same. The only thing working is transform.translate, but as the player gets really fast, he goes through the walls. This is kinda getting on my nerves…
Anyone knows where the problem is? Maybe i should use some raycast and use transform.translate instead of physics?
(using unity 5.6.1f)