View unanswered posts | View active topics It is currently Sat Jan 11, 2025 10:26 am



Reply to topic  [ 11 posts ] 
 Follow 
Author Message
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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


Tue Jun 09, 2009 1:17 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Follow
I need to see the create code.


Tue Jun 09, 2009 1:29 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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


Tue Jun 09, 2009 1:36 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Follow
Problem 1:
Code:

   self.parent.Team = self.Team


Problem 2 is that curdist might be to low.


Tue Jun 09, 2009 1:49 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Follow
So what do i change it to?


Tue Jun 09, 2009 5:30 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Follow
How fast is the pixel being fired?


Tue Jun 09, 2009 5:53 am
Profile
User avatar

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


Tue Jun 09, 2009 8:11 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Follow
What about self.Pos = self.parent.Pos? I need it in update as well.


Tue Jun 09, 2009 7:08 pm
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Follow
How about just making the MOPixel home in on the parent actor.
Like a missile.
Or, is that what you are doing?


Tue Jun 09, 2009 7:10 pm
Profile WWW

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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
Wed Jun 10, 2009 12:36 am
Profile WWW
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Follow
Zalo does it again it!
:D


Wed Jun 10, 2009 6:31 am
Profile WWW
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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.212s | 14 Queries | GZIP : Off ]