1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

MoveTo causes Pawn to circle around target location

Discussion in 'Programming' started by DasGoST, Jun 20, 2005.

  1. DasGoST

    DasGoST New Member

    Joined:
    Jun 17, 2005
    Messages:
    4
    Likes Received:
    0
    I've been working on an AI-controlled Pawn that basically follows a target actor's movement throughout the level. I'm using MoveTo() and MoveTowards() latent functions, but I've been having some weird behavior with 'em.

    When the Pawn in question gets close enough to its target location, for some reason it starts "orbiting" around it and the function returns only when MoveTimer runs out. The only other special consideration is that the Pawn's physics are set to PHYS_Flying.

    If the Move functions are not precise, is there any way to control the distance at which the Pawn "orbits" its target, so you could stop it with code or keep executing? Right now it seems to be orbiting at a radius of about 80-100u's...
     
  2. BlueNeptune

    BlueNeptune New Member

    Joined:
    Oct 26, 2003
    Messages:
    32
    Likes Received:
    0
    Does the Actor that your Pawn is moving to have collision enabled? That might be why he can't get to it. If using MoveTo(), try making the destination vector slightly offset from the Actor's location (just enough to be out of the collision radius).

    If that doesn't work, you can just check the distance in Timer() and stop the loop if the Pawn is within 80-100u's...
     
  3. DasGoST

    DasGoST New Member

    Joined:
    Jun 17, 2005
    Messages:
    4
    Likes Received:
    0
    I've checked the collision options. The tracker Pawn is set to false for the three options; the target Actor has default collisions set. I don't think the target is actually blocking the tracker (not entirely sure how the blocking and collision options interact for two actors). Anyone care to clarify?

    The orbiting effect still occurs when you call MoveTo() with an arbitrary location on empty space.

    I'll check the Timer() alternative tonight; should work. My only concern is if you can break a latent function by calling Goto('Tag') instead of GotoState() from within a function. I guess a little experimentation is at hand. I'll post my findings in a while...
     
  4. DasGoST

    DasGoST New Member

    Joined:
    Jun 17, 2005
    Messages:
    4
    Likes Received:
    0
    Findings posted

    Alright, the Timer method works. I wrote a Timer function that sends the tracker into a Waiting state and stops by disabling physics via SetPhysics(PHYS_None);

    The problem that arises is that there's no way to orient the tracker towards its goal after physics are disabled. If you turn them on, the tracker will just keep circling around. I tried setting the velocity and acceleration of the tracker to 0, but there's no way to stop it beyond disabling physics.

    I recall seeing this discussion in another thread...

    I've been researching how the Move functions work. I've found a few variables in Controller regarding targeted movement: Focus, Destination, MoveTarget, MoveTimer, etc. This and the Unreal Docs lead me to think there's a chance to control movement without calling the latent functions. I'll get back to you on that...
     
  5. BlueNeptune

    BlueNeptune New Member

    Joined:
    Oct 26, 2003
    Messages:
    32
    Likes Received:
    0
    If I remember correctly, there is a latent function that stops the move. I can't remember then name of it.

    I'll post it if I find it...
     
  6. DasGoST

    DasGoST New Member

    Joined:
    Jun 17, 2005
    Messages:
    4
    Likes Received:
    0
    Success!

    I finally found a way to make the object stop without changing the physics settings! Turns out I was zeroing out the velocity and acceleration for the object, but AccelRate was still adding to the acceleration despite the latent function had already returned.

    So to stop the object, all you have to do is zero out AccelRate and that's it! Same thing for rotation with RotationRate... The only issue is you have to restore those values if you want the object to move again. I used AccelRate = self.default.AccelRate and worked just fine!

    There are two other threads of people with similar problems. If they haven't worked it out yet, it would be nice to point them here...
     

Share This Page