zoom towards testicles instead of feet
This commit is contained in:
parent
afc44710f2
commit
50952309f4
@ -13,6 +13,14 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
|
func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
|
||||||
|
// Adjust target position to be at character's torso height (about half character height)
|
||||||
|
characterHeight := float32(32.0) // Assuming character is roughly 32 units tall
|
||||||
|
targetPos := rl.Vector3{
|
||||||
|
X: player.X,
|
||||||
|
Y: player.Y + characterHeight*0.5, // Focus on middle of character
|
||||||
|
Z: player.Z,
|
||||||
|
}
|
||||||
|
|
||||||
wheelMove := rl.GetMouseWheelMove()
|
wheelMove := rl.GetMouseWheelMove()
|
||||||
if wheelMove != 0 {
|
if wheelMove != 0 {
|
||||||
cameraDistance += -wheelMove * 5
|
cameraDistance += -wheelMove * 5
|
||||||
@ -47,9 +55,9 @@ func UpdateCamera(camera *rl.Camera3D, player rl.Vector3, deltaTime float32) {
|
|||||||
cameraPitchRad := float64(cameraPitch) * rl.Deg2rad
|
cameraPitchRad := float64(cameraPitch) * rl.Deg2rad
|
||||||
|
|
||||||
camera.Position = rl.Vector3{
|
camera.Position = rl.Vector3{
|
||||||
X: player.X + cameraDistance*float32(math.Cos(cameraYawRad))*float32(math.Cos(cameraPitchRad)),
|
X: targetPos.X + cameraDistance*float32(math.Cos(cameraYawRad))*float32(math.Cos(cameraPitchRad)),
|
||||||
Y: player.Y + cameraDistance*float32(math.Sin(cameraPitchRad)),
|
Y: targetPos.Y + cameraDistance*float32(math.Sin(cameraPitchRad)),
|
||||||
Z: player.Z + cameraDistance*float32(math.Sin(cameraYawRad))*float32(math.Cos(cameraPitchRad)),
|
Z: targetPos.Z + cameraDistance*float32(math.Sin(cameraYawRad))*float32(math.Cos(cameraPitchRad)),
|
||||||
}
|
}
|
||||||
camera.Target = player
|
camera.Target = targetPos
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user