Jump to content

Help me, Collision Camera.


Yue
 Share

Recommended Posts

 

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 

image.png.60c881675589738299b96988a7dd450c.png

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

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

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

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...