Russell Posted February 16, 2020 Share Posted February 16, 2020 Hello again... I'm working on a last map for showing CREDITS about my game. I will use a camera attached to a moving platform, using platform.lua and platformwaypoint.lua for the points of the trip. And the idea is the camera move across the map where the credits are exposed... I have designed the trip, and the platform with the camera attached on it moves ok. But I have an important question about a problem whose the solution I have not been able to find in the forums, neiher looking on Google... Is there a way (or command) with which I can make the moving platform turn in the direction that is moving? Like something moving always "Face of motion". At this moment, when the platform turn left or right on the next waypoints, the platform still looking in the same direction. And the camera attached on it too. I want the platform turn in face of motion. ¿Is possible? Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted February 16, 2020 Share Posted February 16, 2020 I think point is what you are after. https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Transform_Point 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted February 16, 2020 Author Share Posted February 16, 2020 13 hours ago, Thirsty Panther said: I think point is what you are after. https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Transform_Point I tried to understand this entity "Point". I have done the example with the blue box... But i don't know how works or how apply this entity to my moving platform. I'm reading other post in the forum about how use this "point", but i don't understand how use it anyway... ???? Quote Link to comment Share on other sites More sharing options...
Russell Posted February 16, 2020 Author Share Posted February 16, 2020 I'm testing this with this example platform (The red face should always go to the front, but it doesn't? I don't know how solve my case of how platform turn face direction of motion and i don't understand "Point" entity sintax to help me with this... In other engines, like valve's Hammer, we have this option: In Leadwerks is anything like that or a code for Moving Platforms? Quote Link to comment Share on other sites More sharing options...
Russell Posted February 17, 2020 Author Share Posted February 17, 2020 I think this is the part of the platform code i need to put the POINT code entity (last part of this code between comments): function Script:SetTarget(newTarget) self.currentPosition = self.entity:GetPosition() self.originPosition = self.entity:GetPosition() self.targetPosition = newTarget:GetPosition() self.distance = self.originPosition:DistanceToPoint(self.targetPosition) self.target = newTarget local pos = self.entity:GetPosition(true) local targetpos = self.target:GetPosition(true) local pin = pos - targetpos self.distance = pin:Length() pin = pin:Normalize() if self.joint then self.joint:DisableMotor() self.joint:Release() end self.joint=Joint:Slider(targetpos.x,targetpos.y,targetpos.z,pin.x,pin.y,pin.z,self.entity,nil) self.joint:EnableMotor() self.joint:SetMotorSpeed(self.speed) self.joint:SetAngle(-self.distance) --Here i think is needed Point code to turn my platform face direction of motion: self.Transform:Point(targetpos.x,targetpos.y,targetpos.z,nil,model) --Don't know what parameters i need to platform FACE up direction to the pivot waypoint... end Thanks in advance for your help!! Quote Link to comment Share on other sites More sharing options...
Marcousik Posted February 20, 2020 Share Posted February 20, 2020 Here I don't know how point() function is doing with joint functions... But I would calculate a simple cosinus/sinus/tan math functions to determine the angle you need for your entity to face the waypoint. Then use a joint kinematic on the entity instead of slider: https://www.leadwerks.com/learn?page=API-Reference_Object_Joint_Kinematic move with joint:SetTargetPosition() https://www.leadwerks.com/learn?page=API-Reference_Object_Joint_SetTargetPosition So then just apply the angle with joint:SetTargetRotation() https://www.leadwerks.com/learn?page=API-Reference_Object_Joint_SetTargetRotation 1 Quote Link to comment Share on other sites More sharing options...
reepblue Posted February 20, 2020 Share Posted February 20, 2020 When importing your models, the front should always be Z positive. Then you can use The point function of the entity to point to it's target like: self.enitity:Point(self.target,2,1,0) Only concern I have is that the joint locks the rotation of the entity so you might need to disable the mass of the train before you can manipulate the rotation. Then re-apply the mass. Never did this, but that would be my first attempt. 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Russell Posted February 20, 2020 Author Share Posted February 20, 2020 Thanks for your answers!! I will study all of them, for make my platform turn face of motion. I'm little confuse about how use of all those entities in learn page wiki, but i will manage to success this question about the platform. I don't know if I'll get it. But if I succeeded, I will post it here my solution. Many thanks team!! I am very proud and satisfied of the people in this forum. ☺️☺️☺️☺️ Quote Link to comment Share on other sites More sharing options...
Marcousik Posted February 21, 2020 Share Posted February 21, 2020 The kinematic joint functions are looking first more complicated as they are but it runs ok. Just create the joint in the center - entity:GetPosition() - of the entity you want to move. And the joint:SetTargetPosition + joint:SetTargetRotation are very intuitive. Use a mass of about 3 or 5 not more or it won't move. Feel free to ask if problems About what reepblue said, I suppose that the slider joint will force the rotation as soon as the mass is restored. (but not tested) What you could do is to move a pivot with mass along the slider joint and put your box as child and use point() on the child 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.