Rick Posted November 26, 2014 Share Posted November 26, 2014 Has anyone gotten the Point function to work with a character controller? I have the following call that gets hit once (flags prevent it from getting hit after that) and it doesn't rotate at all. -- where this script is attached to a character model that has the character controller set for it self.entity:Point(self.pointAtEntity, 1, 500) Quote Link to comment Share on other sites More sharing options...
xtreampb Posted November 26, 2014 Share Posted November 26, 2014 character controllers need to use setinput to rotate. see thread here Quote bool Life() { while(death=false) { if(death==true) return death; } } I have found the secret to infinite life Did I help you out? Like my post! Link to comment Share on other sites More sharing options...
Josh Posted November 27, 2014 Share Posted November 27, 2014 You can use Math::ATan2 to figure out the correct angle from the difference between the two entity positions. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted November 27, 2014 Author Share Posted November 27, 2014 I have the following attached to the character but it doesn't work. the pos parameter is the entity to point at function Script:FaceEntity(pos2) local pos1 = self.entity:GetPosition(true) local v = Vec2() v.y = pos1.x - pos2.x v.x = pos1.z - pos2.z local angle = Math:ATan2(v.y, v.x) self.entity:SetRotation(0, angle, 0) end Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 27, 2014 Share Posted November 27, 2014 you are still not using SetInput... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted November 27, 2014 Author Share Posted November 27, 2014 Dammnit I don't want to use SetInput This still didn't seem to work when I changed it to: function Script:FaceEntity(pos2) local pos1 = self.entity:GetPosition(true) local v = Vec2() v.y = pos1.x - pos2.x v.x = pos1.z - pos2.z local angle = Math:ATan2(v.y, v.x) self.entity:SetInput(angle, 0) end Note that my game is a point and click so I don't call SetInput() like in a fps or third person game moving with the keyboard. It's all GoToPoint() driven. Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 27, 2014 Share Posted November 27, 2014 I thought you hated point-n-clicks? In any case, what about it doesn't work? Is it not returning the right angle? And wouldn't you still have to use SetInput() to move your character to the 'GoToPoint'? In LE2, I used essentially the same setup: function PerfectAngle(pos1,pos2) local dx, dz dx = pos1.x - pos2.x dz = pos1.z - pos2.z return math.deg(math.atan2(-dx,dz)) end ... perfectangle = PerfectAngle(gotohere,player.position) angle=IncAngle(perfectangle,angle,5/AppSpeed()) ... ... player:Update(angle,move,0,0,500,1,0) 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted November 27, 2014 Author Share Posted November 27, 2014 And wouldn't you still have to use SetInput() to move your character to the 'GoToPoint'? Nope. GoToPoint() is magic Had some code structure issues but it's "working". Right now he points in the complete opposite direction. Getting closer. [edit] Got it. Thanks for the code mac. Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 27, 2014 Share Posted November 27, 2014 Nope. GoToPoint() is magic Had some code structure issues but it's "working". Right now he points in the complete opposite direction. Getting closer. yeah i dont use that... it feels dirty.. like cheating... well without seeing all of your code or character setup i can only guess, but if you notice i am using a 'negative' value when calculating ATan2 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.