Timeline for Why does this code behave strangely with different camera angles?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 9 at 19:51 | comment | added | DMGregory♦ | I would recommend the code I linked, rather than the code you've written there. π | |
Aug 9 at 18:53 | comment | added | Bunabyte |
@DMGregory I tried doing something like moveDir = camTransform.rotation * moveDir; , but the character still only seems to move at 45 degree angles. This means that if the camera yaw is something like 30, then pressing the "up" key won't make the character face forwards relative to the camera and move them in that direction like it should.
|
|
Aug 9 at 18:22 | comment | added | DMGregory♦ | I usually use a quaternion to define a camera-relative coordinate frame for input, and use that to rotate my input vector into world space. I'd also recommend applying acceleration/deceleration to both axes in one function call instead of separately in four | |
Aug 8 at 17:03 | history | edited | Bunabyte | CC BY-SA 4.0 |
Simplified my example code
|
Aug 7 at 20:24 | history | edited | Bunabyte | CC BY-SA 4.0 |
Add link to example project
|
Aug 7 at 20:04 | history | edited | Bunabyte | CC BY-SA 4.0 |
Only show important code snippets
|
Aug 7 at 7:49 | history | asked | Bunabyte | CC BY-SA 4.0 |