So the problem is that when I have the first 3 lines of code in there, the gravity is cut down most of the way and my character falls slowly, also the jump part of the code stops working. When I jump it moves up about .1 on the y axis, then starts falling slowly back to the ground. But when I have line 1-3 commented out the jump script works.
Is there something I can do to line 3 so I can keep line 1-2 the same and for the jump to work?
Do you know what an impulse force is? It adds the force you specify onto the velocity of the Rigidbody immediately i.e. velocity += force.
This is what you should be doing above instead of overwriting the Rigidbody velocity. Either that or you can simply add your ‘forwardVel + horizontalVel’ to the velocity.
Whelp, I tested this, and now I have another problem. It applys it globally, but I need it to apply it locally because my player rotates. How can I do the impulse force and apply it locally?
Great that you test “this” but unfortunatley we can’t see your code. You obviously apply an impulse force in local-space by passing it a local-space vector just like you did when you set a local-space vector for the velocity. Nothing changes.
Note that you’re using Vector3 which might be convenient but 2D requires a Vector2. It performs a conversion for you by simply stripped the Z away but note that this can cause subtle problems if you’re not using vectors aligned to the XY plane.