Question by
Rodehaast · Jan 11 at 01:52 AM ·
c#scripting problemscripting beginnerjumping
Cant Jump because of my movement code.
if i disable the movement code while juming, i lose all velocity.
Vector2 targetDir = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
targetDir.Normalize();
currentDir = Vector2.SmoothDamp(currentDir, targetDir, ref currentDirVelocity, moveSmoothTime);
Vector3 velocity = (transform.forward * currentDir.y + transform.right * currentDir.x) * CurrentSpeed;
rb.velocity = velocity * Time.deltaTime;
^ the code for my movement.
rb.velocity = new Vector3 (rb.velocity.x, JumpStrength * JumpDeaccelValue, rb.velocity.z);
^ my jumpcode, i know the problem is me setting the velocity, but i have no idea how to fix it.
Comment