Skip to content

function rl.UpdateCamera() isn't able to move the cameraΒ #499

@tuzu128

Description

@tuzu128

Expected behavior:
When I pass rl.CameraFree as a mode to UpdateCamera() and press W/A/S/D it will move me in the corresponding behavior
Actual behavior:
It dose nothing when I press W/A/S/D.

My system:
Alpine linux
mesa-25.0.5
6.12.26-1-lts
river (wayland)
go version go1.24.2 linux/amd64
AMD Ryzen 5 3400G
I am on the latest version of raylib-go

You can reproduce it with the flowing code:

package main

import (
	"strconv"

	rl "github.com/gen2brain/raylib-go/raylib"
)

func main() {
	rl.InitWindow(1080, 720, "Raylib")
	defer rl.CloseWindow()
	rl.SetTargetFPS(60)

	var camera rl.Camera3D
	camera.Position = rl.Vector3{X: 10, Y: 10, Z: 10}
	camera.Target = rl.Vector3{X: 0, Y: 0, Z: 0}
	camera.Up = rl.Vector3{X: 0, Y: 1, Z: 0}
	camera.Fovy = 45.0
	camera.Projection = rl.CameraPerspective
	rl.DisableCursor()

	for !rl.WindowShouldClose() {
		rl.UpdateCamera(&camera, rl.CameraFree)

		rl.BeginDrawing()
		{

			rl.ClearBackground(rl.White)

			rl.BeginMode3D(camera)
			{
				rl.DrawCube(rl.Vector3{X: 0, Y: 1, Z: 0}, 2.0, 2.0, 2.0, rl.Brown)
				rl.DrawCubeWires(rl.Vector3{X: 0, Y: 1, Z: 0}, 2.0, 2.0, 2.0, rl.Black)
				rl.DrawGrid(80, 1)
			}
			rl.EndMode3D()

			rl.DrawRectangle(0, 0, 90, 90, rl.Black)
			rl.DrawFPS(0, 0)
			rl.DrawText("X: "+strconv.Itoa(int(camera.Position.X)), 0, 20, 20, rl.White)
			rl.DrawText("Y: "+strconv.Itoa(int(camera.Position.Y)), 0, 40, 20, rl.White)
			rl.DrawText("Z: "+strconv.Itoa(int(camera.Position.Z)), 0, 60, 20, rl.White)
		}
		rl.EndDrawing()
	}
}

or this example .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions