Data Realms Fan Forums
http://45.55.195.193/

Follow
http://45.55.195.193/viewtopic.php?f=73&t=15264
Page 1 of 1

Author:  Mind [ Tue Jun 09, 2009 1:17 am ]
Post subject:  Follow

Okay. I have an MOPixel that's sposed to find thenearest actor and follow it, but whenever i try it, CC tells me the value is nil. Like "self.Pos = self.parent.Pos" says parent is nil, but i have it in create.

Thanks

Author:  mail2345 [ Tue Jun 09, 2009 1:29 am ]
Post subject:  Re: Follow

I need to see the create code.

Author:  Mind [ Tue Jun 09, 2009 1:36 am ]
Post subject:  Re: Follow

Code:
function Create(self)
   local curdist = 15;
    for actor in MovableMan.Actors do
   local avgx = actor.Pos.X - self.Pos.X;
   local avgy = actor.Pos.Y - self.Pos.Y;
   local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
   if dist < curdist then
       curdist = dist;
       self.parent = actor
   self.parent.Team = self.Team   
   end
    end
end

Author:  mail2345 [ Tue Jun 09, 2009 1:49 am ]
Post subject:  Re: Follow

Problem 1:
Code:

   self.parent.Team = self.Team


Problem 2 is that curdist might be to low.

Author:  Mind [ Tue Jun 09, 2009 5:30 am ]
Post subject:  Re: Follow

So what do i change it to?

Author:  mail2345 [ Tue Jun 09, 2009 5:53 am ]
Post subject:  Re: Follow

How fast is the pixel being fired?

Author:  piipu [ Tue Jun 09, 2009 8:11 am ]
Post subject:  Re: Follow

Change curdist to at least 50. Change the line quoted by mail to
Code:
self.Team = self.parent.Team
That should fix it.

Author:  Mind [ Tue Jun 09, 2009 7:08 pm ]
Post subject:  Re: Follow

What about self.Pos = self.parent.Pos? I need it in update as well.

Author:  CrazyMLC [ Tue Jun 09, 2009 7:10 pm ]
Post subject:  Re: Follow

How about just making the MOPixel home in on the parent actor.
Like a missile.
Or, is that what you are doing?

Author:  zalo [ Wed Jun 10, 2009 12:36 am ]
Post subject:  Re: Follow

How about you just use my example?

One of the drawbacks though is that there can only be one. Though, that's easily fixable.

Attachments:
File comment: All you have to do is pick it up, and it starts giving you health.
TestShield.rte.rar [2.24 KiB]
Downloaded 212 times

Author:  CrazyMLC [ Wed Jun 10, 2009 6:31 am ]
Post subject:  Re: Follow

Zalo does it again it!
:D

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