Yue Posted June 15, 2018 Share Posted June 15, 2018 Hi, can you help me, please? What happens is that I'm throwing a beam from a pivot ("cube") from the center of the character to the camera. The idea is to detect the collision of this beam to stop the movement of the camera when it touches a wall or the ground, but initially I can't detect the end of the beam where this collision should happen, my logic tells me I'm doing well but obviously I'm not. Any suggestions. Translated with www.DeepL.com/Translator Script.Camara = nil --entity "Camara" posCamara = Vec3() pivote = Vec3() posPivote = Vec3() function Script:UpdateWorld() GiroCamara(self) -- Colision Camara posPivote = self.entity:GetPosition(true) posCamara = self.Camara:GetPosition(false) if world:Pick( posPivote.x, posPivote.y, posPivote.z, posCamara.x, posCamara.y, posCamara.z, PickInfo(), 0, true ) then System:Print("Col OK") else System:Print( "Col Not") end end -- Giro Camara libre function GiroCamara(self) --Get the mouse movement local sx = Math:Round(context:GetWidth()/2) local sy = Math:Round(context:GetHeight()/2) local mouseposition = window:GetMousePosition() local dx = mouseposition.x - sx local dy = mouseposition.y - sy --Adjust and set the camera rotation pivote.x = pivote.x + dy / 10.0 pivote.y = pivote.y + dx / 10.0 self.entity:SetRotation(pivote) --Move the mouse to the center of the screen window:SetMousePosition(sx,sy) if pivote.x >= 45 then pivote.x = 45 elseif pivote.x <= -45 then pivote.x = -45 end end Quote Link to comment Share on other sites More sharing options...
havenphillip Posted June 15, 2018 Share Posted June 15, 2018 Can you explain this again? You want the camera to shoot a beam or you want to shoot a beam at the camera? You want the camera to stop or the beam? Quote Link to comment Share on other sites More sharing options...
Yue Posted June 15, 2018 Author Share Posted June 15, 2018 The idea is that from the center of the character (Pivot) lightning to the position of the camera, with the aim of recognizing when the camera touches an entity, such as wall or floor. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 15, 2018 Share Posted June 15, 2018 Note that the pickinfo object needs to be created before you do a pick. local pickInfo = Pickinfo() if world:Pick( posPivote.x, posPivote.y, posPivote.z, posCamara.x, posCamara.y, posCamara.z, pickInfo, 0, true ) then System:Print(pickInfo.position) end 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted June 16, 2018 Author Share Posted June 16, 2018 I'll tell you something, after trial and error, I found out that I had a loaded cube-shaped mesh that was the central pivot of the character, if I use a lightning bolt using a mesh it doesn't work, and I don't understand why. However if I create a cube from the Leadwerks editor and put it as the central pivot point of the character if it works, any suggestions as to why it doesn't work with a loaded mesh? Translated with www.DeepL.com/Translator Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.