Hot answers tagged

2

Don't scale your jump velocity by Time.deltaTime What that says is "If I running at a low framerate, jump higher" which is not what you want. You want a consistent change in velocity no matter whether the button was pressed on a short frame or a long frame. For consistency, you'll want to put your falling acceleration in FixedUpdate, so you get the same ...


1

This happens because FixedUpdate() is not meant for input handling, as it runs every a certain amount of time (specified in settings) and not in every frame so it's not guaranteed to run every frame. You should add it to the Update() method instead, which is guaranteed to run every frame.


1

You have at least one obvious error at hand. foreach (RectangleShape obstacles in JumpAtObjectList) { MainPlayer.Jump(deltaTime, obstacles); break; } break tells the foreach loop to exit and since there is no condition, it will always exactly run one time for the first obstacles in JumpAtObjectList. What you probably wanted is to check if the ...


1

The z-coordinate given to ScreenToWorldPoint is the distance from the camera plane. If you set z to 0, the position returned will be in the camera's plane. Is the ground plane at (0,0,0)? And the camera is at (0,0,-z) and pointing along the +z direction?


1

for(int i=0; i< (tiles.length); i++) { colours[i*4+ 0] = 0xff00ff; colours[i*4+ 1] = 0x0000ff; colours[i*4+ 2] = 0xffff00; colours[i*4+ 3] = 0xffffff; } The For-Loop at the start is generating groups of four colour entries based on how many tiles you have. It's a little convoluted to read at a glance and given choice I'...


1

You should not change the velocity of the RigidBody directly. Try using AddForce instead. if(other.gameObject.transform.position.x > transform.position.x) { rb.AddForce(-hurtForce,rb.velocity.y,0,ForceMode.Acceleration); }


Only top voted, non community-wiki answers of a minimum length are eligible