Slastraf Posted November 21, 2015 Share Posted November 21, 2015 Above some screenshots that are important to understand the problem. function Script:UpdatePhysics() self.entity:Point(self.target, 1, Time:GetSpeed() * self.rotSpeed) end This is a part of my code. The first screenshot is what happens when i run the game. The crawler runs around a path, the turret points at him but is rotated in negative y. What can I do to prevent this ? Quote Link to comment Share on other sites More sharing options...
f13rce Posted November 21, 2015 Share Posted November 21, 2015 Try something like this after calling Point: Vec3 newRot = self.entity:GetRotation(true) self.enitity:SetRotation( Vec3( newRot.x, -newRot.y, newRot.z ), true) This will negate the Y rotation for you. If this rotates the turret on the wrong axis then you can try adding a - before newRot.x or newRot.z. Quote Using Leadwerks Professional Edition (Beta), mainly using C++. Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz Previously known as Evayr. Link to comment Share on other sites More sharing options...
Slastraf Posted November 22, 2015 Author Share Posted November 22, 2015 self.vector = self.target:GetPosition(true)-self.entity:GetPosition(true) self.entity:AlignToVector(self.vector:Normalize(),2) local newRot = self.entity:GetRotation(true) self.entity:SetRotation( Vec3( 90, -180+newRot.y, newRot.z ), true) Try something like this after calling Point: Vec3 newRot = self.entity:GetRotation(true) self.enitity:SetRotation( Vec3( newRot.x, -newRot.y, newRot.z ), true) This will negate the Y rotation for you. If this rotates the turret on the wrong axis then you can try adding a - before newRot.x or newRot.z. That helped in parts, at the top my new script. Quote Link to comment Share on other sites More sharing options...
holschuh Posted November 24, 2015 Share Posted November 24, 2015 Hi, make an hidden helper sphere at cannon pos and point it to the target then get y-rotation from this helper sphere and put it to the cannon (maybe add 180 to flip) tryed quick code down there but not tested carefull to free the helper... helper = Model:Sphere() helper:Hide() helper:SetColor(0.0,1.0,1.0) helper:SetPosition(self.entity:GetPosition(true),true) helper:Point(self.target, 1, Time:GetSpeed() * self.rotSpeed) self.entity:SetRotation(self.entity:GetRotation(true).x,self.helper:GetRotation(true).y+180 ,entity:GetRotation(true).z,true) cu Volker Quote Link to comment Share on other sites More sharing options...
Slastraf Posted November 24, 2015 Author Share Posted November 24, 2015 Volker I already got it working, above the script. But thanks anyway 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.