View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:46 pm



Reply to topic  [ 11 posts ] 
 Problems with vector DegRotate and other Qs 
Author Message

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Problems with vector DegRotate and other Qs
How are you defining turnamount?


Wed May 20, 2009 1:14 am
Profile

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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
Profile

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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
Profile

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post 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
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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
Profile

Joined: Sun May 18, 2008 7:49 am
Posts: 23
Reply with quote
Post Re: Problems with vector DegRotate and other Qs
How do I convert from 'number' to 'custom [float]'?


Fri May 22, 2009 6:12 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.071s | 14 Queries | GZIP : Off ]