ToniBartoli Posted February 7, 2019 Share Posted February 7, 2019 Hello, i am working on a game in the style of Resident Evil with fixed camera angles, i actually have a room with 1 cube as trigger and 2 cameras placed at different points of view, and actually when i start the game the first camera is active but i want the second camera become active when i hit the trigger, or maybe only one camera that change it's position when i hit the trigger. I want to learn LUA, the problem is, there is no serious tutorial on Internet or i didn't find one yet. Thank You Quote Link to comment Share on other sites More sharing options...
Slastraf Posted February 7, 2019 Share Posted February 7, 2019 mabye you could have only one camera in the scene, and make a pivot object with the rotation and position of the second camera. And then move the first camera to the pivot rotation and position when the player hits the trigger. And maybe store a reference to the pivot in each trigger, so that you can choose later when you have alot of camera changes Quote Link to comment Share on other sites More sharing options...
ToniBartoli Posted February 7, 2019 Author Share Posted February 7, 2019 @Slastraf Thank you for your reply, indeed this is more neat to have only one camera that change position when i hit the trigger. Ok now in my scene, i have only one camera, a cube as trigger and a pivot placed as the second camera, what next? How to make them working together? Quote Link to comment Share on other sites More sharing options...
Slastraf Posted February 7, 2019 Share Posted February 7, 2019 17 minutes ago, ToniBartoli said: @Slastraf Thank you for your reply, indeed this is more neat to have only one camera that change position when i hit the trigger. Ok now in my scene, i have only one camera, a cube as trigger and a pivot placed as the second camera, what next? How to make them working together? if you would go to the learn section, soon you would know. But anyway I will give you a start. make a script on the trigger and put this at the top: Script.pivot = nil --entity "Cam Tp Pivot" --pivot the camera teleports to Script.enabled = true then in the scene drag the pivot in there now in the collision function, which is called every time something collides with it, even if its a trigger, put this: function Script:Collision(entity, position, normal, speed) if self.enabled then if(entity:GetKeyValue("type") == "player")then if(self.pivot) then entity.script.camera:SetPosition(self.pivot:GetPosition(true)) entity.script.camera:SetRotation(self.pivot:GetRotation()) end end end end you can read it line by line, it s pretty self explainatory. the entity in the function paramter is everything that collides with the trigger. This would work if the camera is referenced in the player. But I dont know where your camera is in the scene, youcould use this to find it: self.camera = world:FindEntity("Camera") Quote Link to comment Share on other sites More sharing options...
ToniBartoli Posted February 7, 2019 Author Share Posted February 7, 2019 Thank You, i will check this out. Then, i will go to the learn section. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 7, 2019 Share Posted February 7, 2019 Here is a playlist to learn Lua and some lua specific functionality with Leadwerks. Quote Link to comment Share on other sites More sharing options...
ToniBartoli Posted February 7, 2019 Author Share Posted February 7, 2019 @AggrorJorn Thank You 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.