playMaker

Author Topic: Bug in SetAgentDestinationAsGameObject  (Read 2785 times)

yezzer

  • Playmaker Newbie
  • *
  • Posts: 24
    • Follow me on Twitter
Bug in SetAgentDestinationAsGameObject
« on: June 18, 2012, 04:20:42 AM »
I can't use the built-in bug reporter because of the crossdomain.xml error.

Copying the report I wrote:


Potential bug in SetAgentDestinationAsGameObject.

If SetAgentDestinationAsGameObject is called twice on the same destination, this line of code means the destination is never set:
if (deltaPosition.sqrMagnitude>squareDistance)

because of this: Vector3 deltaPosition = newPosition-lastPosition;
Freelance games & App developer using Unity3D, Flash & Adobe AIR for web, iOS, & Android. Interested in AR & other emerging tech.
@yezzer

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Bug in SetAgentDestinationAsGameObject
« Reply #1 on: June 20, 2012, 01:51:09 AM »
Hi,

 I am not sure I follow. This action has a threshold implementation so that I only tell the agent to recompute its path if the gameObject target has moved enough. This action is supposed to stay active for the duration of which you want the agent to follow this gameObject. It's by default using "everyframe" if you will.

so calling this action twice has no additinal effect at all if the gameObject has not moved. But anyway, the lastPosition is set after I made sure I called "setDestination", so the deltaposition.sqrMagnitude can not be the same as squareDistance, so the test will pass and setDestination will be called. Only it will have no effect because on the second time you called it, if that gameObject has not moved, the path is identical. IF, however in between these two calls, the target has indeed moved, the destination will be set and the agent will recompute its path.

Maybe I am missing your point?

 Bye,

 Jean