Author |
Message |
alfie275
Joined: Sun May 18, 2008 7:49 am Posts: 23
|
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.
|
Tue May 19, 2009 8:27 pm |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
Re: Problems with vector DegRotate and other Qs
How are you defining turnamount?
|
Wed May 20, 2009 1:14 am |
|
|
alfie275
Joined: Sun May 18, 2008 7:49 am Posts: 23
|
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
|
Wed May 20, 2009 5:47 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
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.
|
Wed May 20, 2009 7:11 pm |
|
|
alfie275
Joined: Sun May 18, 2008 7:49 am Posts: 23
|
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.
|
Wed May 20, 2009 10:35 pm |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
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.
|
Thu May 21, 2009 12:25 am |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
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.
|
Thu May 21, 2009 1:47 am |
|
|
piipu
Joined: Mon Jun 30, 2008 9:13 pm Posts: 499 Location: Finland
|
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.
|
Thu May 21, 2009 8:48 am |
|
|
alfie275
Joined: Sun May 18, 2008 7:49 am Posts: 23
|
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]'.
|
Thu May 21, 2009 6:39 pm |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
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
|
Thu May 21, 2009 8:58 pm |
|
|
alfie275
Joined: Sun May 18, 2008 7:49 am Posts: 23
|
Re: Problems with vector DegRotate and other Qs
How do I convert from 'number' to 'custom [float]'?
|
Fri May 22, 2009 6:12 pm |
|
|
|