Jump to content

Recommended Posts

Posted

I am creating a cube for my third person camera pivot. But the cube is not visible, although the camera is pivoting to its position.

 

Camera3rdPerson = {}
Camera3rdPerson.__index = Camera3rdPerson
 
function Camera3rdPerson:New(world)
    local this = setmetatable({}, Camera3rdPerson)
 
    Print(" [Camera3rdPerson] Sistema de cámara orbital inicializado.")
 
 -- 🌌 Crear cámara vinculada al mundo
    local camera = CreateCamera(world:GetWorld())
    camera:SetOrder(-1) -- Se renderiza primero
    camera:SetPosition(0,2,-2)
   
    local pivotCamera = CreateBox(world:GetWorld(), 0.2)
    pivotCamera:SetColor(1, 1, 0, 1) -- Amarillo brillante para debug
    pivotCamera:SetPosition(0, 2, 0,true) -- Altura media, ajustable luego
 
    camera:Point(pivotCamera)

 

image.thumb.png.78d72232e6db8a0421992378dad9df2f.png

 

The cube is there, the camera is looking at it. 

 

function this:Update()
        --Print("📡 [Camera] Update activo en Nivel01.")
 
        pivotCamera:Move(0,0.001,0)
    end



image.thumb.png.cf371ef644c9b22983d1d0023a611281.png

 

The cube is visible and starts to move upwards . 

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

Temporary solution
 

    ---------------------------------------------------
    -- 🔁 Actualizar posición de la cámara cada frame
    ---------------------------------------------------
    function this:Update()
        --Print("📡 [Camera] Update activo en Nivel01.")
       
        if self._forceCheck then
            local _ = pivotCamera:GetHidden()
            self._forceCheck = false
        end
 
      
    end

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

In your code above pivotCamera is being declared as a local variable. The real mystery is how the program is not crashing in the Update method, since there is no global pivotCamera value declared? I need to see your whole code file to tell what is going on.

  • Like 1

Let's build cool stuff and have fun. :)

Posted
4 hours ago, Josh said:

In your code above pivotCamera is being declared as a local variable. The real mystery is how the program is not crashing in the Update method, since there is no global pivotCamera value declared? I need to see your whole code file to tell what is going on.

Ok i sent the file by inbox

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted
1 hour ago, Josh said:

Closing due to lack of information.

At the moment, until now I see it. Wait, I'll send you the project inbox.

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

Ok, I already sent the project. Sorry, I had not noticed this entry.

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

  • 3 weeks later...
Posted

This is what I see when I run the project:

image.thumb.png.740d080a905d840672d6a81181cfd14a.png

You code is using 0 for the size of the box, which will make it not visible.

local pivotPlayer = CreateBox(world, 0)

When I changed the size to 0.2, I see this:

image.thumb.png.c8ce0d01bd7d9f69ed057bb23b4029ba.png

How do I make the bug occur?

  • Like 1

Let's build cool stuff and have fun. :)

  • Solution
Posted

In your video you are declaring the box variable as a local variable. Therefore, it will go out of scope and be deleted on the next garbage collection cleanup.

When I declared it as a global variable it works as expected.

Player.lua

image.thumb.png.be746d9604985ed1c8e714b5261c856b.png

  • Like 1

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...