View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:11 am



Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
 Quick question about choosing homing targets 
Author Message

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Quick question about choosing homing targets
Hey, I've been working on my KamiCrabs Mod, And I am trying to add homing crabs to it, the homing part works fine, but currently, it likes to lock on to the brain and aim towards that every time, is there a way to set it to ignore Brains?]


Thanks

P.S. Sorry for any confusion that has been caused by my account being deleted, the forums thought it was a spam bot, and thus deleted all my posts.


Sat Dec 22, 2012 7:58 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
In the line where you search the potential target, put "and not actor:HasObjectInGroup("Brains")".

I've never used it, but it's used in the AI and saw it on the wiki, so I doubt that it won't work.


Sat Dec 22, 2012 8:09 pm
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
I Tried that, but no dice. The crab still goes hurtling towards the brain.

Code:
function Update(self)
      
      if self:IsPlayerControlled() == true then
         if  UInputMan:KeyPressed(19) == true then
            self:GibThis()
         end
      end
      if self:IsPlayerControlled() == true then
            if MovableMan:IsActor(self.target) and not self.target:HasObjectInGroup("Brains") then
               if UInputMan:KeyPressed(6) == true then
               self.RotAngle = SceneMan:ShortestDistance(self.Pos,self.target.Pos,true).AbsRadAngle
               self.Vel = Vector(100, 0):RadRotate(self.RotAngle)
                  end
                  
               else
      
         self.shortestdistance = 1
         for actor in MovableMan.Actors do
      if actor.Team ~= self.ignoreteam then
         self.curdist = SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude
         if self.curdist < 500000 and (self.shortestdistance == -1 or self.shortestdistance ~= -1 and self.curdist < self.shortestdistance) then
            self.target = actor
            self.shortestdistance = self.curdist
         end
      end
   end
end
end
end
function Destroy(self)
      if self:IsPlayerControlled() == true then
         if UInputMan:KeyPressed(19) == False then
         self:GibThis()
      end
   end
end
function Create(self)
      self.ignoreteam = self.team
      end


I apologize for my atrocious tabbing.


Sat Dec 22, 2012 8:37 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Code:
      if actor.Team ~= self.ignoreteam and not actor:HasObjectInGroup("Brains") then



There is where it should go, in the part where you are checking which actors are possible candidates, in that way, the actor must be of another team and can't be a brain.

Try to fix your tabbing hehehe


Sat Dec 22, 2012 8:48 pm
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
Alright, It ignores the brains now, but I just realized it doesn't actually home in on anything. It goes flying to the right, ignoring all actors. I probably should have noticed that before now...
I'm guessing the problem is with my rotation script?


edit: Yeah.. I'll work on my tabbing real real real soon...


Sat Dec 22, 2012 8:56 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Well, that script looks a bit wierd.

What is it attached to? An emitter? It doesn't seem like it.


Sat Dec 22, 2012 9:01 pm
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
Well, what its supposed to do is look for the closest enemy, rotate the crab towards it, and set the velocity of the crab. The crab is still an actor, so there is no emitter


Sat Dec 22, 2012 9:19 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Is it printing any errors, or it just won't work?


Sat Dec 22, 2012 9:51 pm
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
No errors, it just sends the crab flying to the right, regardless of where the enemy are.


Sat Dec 22, 2012 10:16 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Well, try reducing that 500000 distance into something smaller, like 250 for testing purposes. Try to make additional checks (printing the presetname of the target, for example, and making sure that it's ID is ~= 255).

Also, don't set the angle you get to RotAngle, since the RotAngle varies easily in any moment. Store it in another variable created by you.


Sat Dec 22, 2012 10:22 pm
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
Okay, the RotAngle is supposed to set the Rotangle, thus turning the crab in the direction of the target.
Is that not what its doing?


Sat Dec 22, 2012 11:56 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Well, yeah. Do you see the body rotating?

Because if it's just moving to the right, there could be two problems; the RotAngle isn't changing at all, or it changes and returns to normal too fast, rotating the velocity to your right, or, you are not setting the angle properly.

I'm more inclined for the first one though, so instead of using self.RotAngle create any other variable and use it, then check if it works.


Sun Dec 23, 2012 12:20 am
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
The body doesn't rotate at all, so I'm going to assume that it is not being set properly.


Sun Dec 23, 2012 1:38 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Quick question about choosing homing targets
Print the RotAngle before and after you make it change.


Sun Dec 23, 2012 1:46 am
Profile

Joined: Sat Dec 22, 2012 3:24 am
Posts: 12
Reply with quote
Post Re: Quick question about choosing homing targets
It says the Rotation is 0 when I press the F key, whichis the key that sends it flying, so it must not be tracking any enemies.


EDIT: I moved the rotation part to rotate as long as it exists, not just when the F key is pressed, and the crab stays standing straight the entire time, as if it were running a keep upright script. So the problem must be in the getting of the targets.

EDIT2: I also set it to print the name of its target, it is targeting itself.


Sun Dec 23, 2012 3:15 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 22 posts ]  Go to page 1, 2  Next

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.050s | 14 Queries | GZIP : Off ]