Jump to content

ALignToVector : entity childs not aligned


YouGroove
 Share

Recommended Posts

The children won't necessarily be aligned, they will just follow the orientation of the parent. This example works as expected:

function App:Start()

--Create a window

self.window = Window:Create()

self.context = Context:Create(self.window)

self.world = World:Create()

local camera = Camera:Create()

camera:Move(0,0,-6)

local light = DirectionalLight:Create()

light:SetRotation(35,35,0)

 

--Create a model

self.model = Model:Box()

 

local child = Model:Box()

child:SetPosition(2,0,0)

child:SetParent(self.model)

child:SetColor(1,0,0)

 

return true

end

 

function App:Loop()

 

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

 

--Get the vector between the mouse position and the center of the screen

local v = self.window:GetMousePosition()

local dx = v.x - self.context:GetWidth()/2.0

local dy = self.context:GetHeight()/2.0 - v.y

v = Vec3(dx,dy,0):Normalize()

 

--Align the model to the vector

self.model:AlignToVector(v,0)

 

Time:Update()

self.world:Update()

self.world:Render()

self.context:Sync()

 

return true

end

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 2 weeks later...

I see this too.. Interestingly, objects dragged in the scene tree to be children in an older build of the editor (Couldn't say which one) work correctly - e.g. I load an old map where a sprite is a 'child' of the camera, and it behaves as expected.

 

In the latest Leadwerks (3.4beta), adding an object as a child of the camera in the Scene tree has no effect on the objects position or orientation, regardless of how the 'parent' camera is moved.

Link to comment
Share on other sites

In the latest Leadwerks (3.4beta), adding an object as a child of the camera in the Scene tree has no effect on the objects position or orientation, regardless of how the 'parent' camera is moved.

 

I also have this happening in my game. From my fpsplayer I added a pivot as a child(drag and drop) that has my gui on it and from it(child) I am calling to another script's function(fpsplayer function) to create a prefab infront of the player. But each time the player moves, the prefab is placed in a different place and never where the setposition was set(directly infront of the fpsplayer)

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...