Data Realms Fan Forums
http://45.55.195.193/

Problems with vector DegRotate and other Qs
http://45.55.195.193/viewtopic.php?f=73&t=14789
Page 1 of 1

Author:  alfie275 [ Tue May 19, 2009 8:27 pm ]
Post subject:  Problems with vector DegRotate and other Qs

whenever I use it it says I am passing a <vector> argument when I am not:
Code:
      self.Vel = self.Vel:DegRotate(turnamount);


Also how would I go about getting a list of all bullets and grenades in MoveableMan, I know .Actors but thats about all.

Author:  Daman [ Wed May 20, 2009 1:14 am ]
Post subject:  Re: Problems with vector DegRotate and other Qs

How are you defining turnamount?

Author:  alfie275 [ Wed May 20, 2009 5:47 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

Code:
if MovableMan:IsActor(self.target) then

local targetdir = Vector(-(self.target.Pos.Y-self.Pos.Y),(self.target.Pos.X-self.Pos.X)).AbsDegAngle;
       if targetdir ~= self.Vel.AbsDegAngle then
      self.Vel = self.Vel:DegRotate(targetdir - self.Vel.AbsDegAngle);
       end




   end

Author:  piipu [ Wed May 20, 2009 7:11 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

Code:
if MovableMan:IsActor(self.target) then
  local targetdir = math.atan2(self.target.Pos.Y-self.Pos.Y),(self.target.Pos.X-self.Pos.X)
  local totalvel = math.sqrt(self.Vel.X ^ 2 + self.Vel.Y ^ 2)
  self.Vel = Vector(totalvel * math.cos(targetdir) , totalvel * math.sin(targetdir))
end

No need to do it the hard way. You may have to negate the first argumen of math.atan2. Can't think right now.

Author:  alfie275 [ Wed May 20, 2009 10:35 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

Yes I suppose I could do it like that but why is the current method not working? I am giving it a number but it thinks I am giving a number and a vector which I am not, I'm concerned it might be broken.

Author:  piipu [ Thu May 21, 2009 12:25 am ]
Post subject:  Re: Problems with vector DegRotate and other Qs

I dunno. I didn't bother to check the lua docs for it or anything. Just use my method if it works.

Author:  Daman [ Thu May 21, 2009 1:47 am ]
Post subject:  Re: Problems with vector DegRotate and other Qs

alfie275 wrote:
Yes I suppose I could do it like that but why is the current method not working? I am giving it a number but it thinks I am giving a number and a vector which I am not, I'm concerned it might be broken.


It thinks you're providing a vector because you are.

Code:
self.Vel:DegRotate(targetdir - self.Vel.AbsDegAngle);


self.Vel is a vector. You should've noticed something odd when it was telling you you provided two arguments. This would be the only way to run the function without passing it as an argument--

Code:
self.Vel.DegRotate(targetdir - self.Vel.AbsDegAngle);


and I'm not sure that would work. It'd probably give you the same no overload message, except your arguments would match perfectly. It's one of the issues I encountered with CastObstacleRay as well.

Author:  piipu [ Thu May 21, 2009 8:48 am ]
Post subject:  Re: Problems with vector DegRotate and other Qs

Code:
SceneMan:CastObstacleRay(Vector(self.Pos.X - self.Vel.X * 4, self.Pos.Y - self.Vel.Y * 4),Vector(avgx,avgy),self.unusedvector,self.unusedvector,0,0,1)

That's a working castobstacleray. /offtopic.

Author:  alfie275 [ Thu May 21, 2009 6:39 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

Ok that is working but now it is complaining I am sending a 'number' instead of a 'custom [float]'.

Author:  Daman [ Thu May 21, 2009 8:58 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

piipu wrote:
Code:
SceneMan:CastObstacleRay(Vector(self.Pos.X - self.Vel.X * 4, self.Pos.Y - self.Vel.Y * 4),Vector(avgx,avgy),self.unusedvector,self.unusedvector,0,0,1)

That's a working castobstacleray. /offtopic.


yeah I know but it's p finnicky about its arguments

Author:  alfie275 [ Fri May 22, 2009 6:12 pm ]
Post subject:  Re: Problems with vector DegRotate and other Qs

How do I convert from 'number' to 'custom [float]'?

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/