onMoveComplete event fires while iso character still moving ?
Shri

Gio,

 

I am working on another isometric game.

Certain things can happen when the iso character is not moving.

The iso character moves on a mouse click similarily to your iso sample.

 

As I wait on the onMoveComplete event for the character, I am noticing the following:

1. onMoveComplete fires multiple times - twice.

2. onMoveComplete fires while the character is still in motion (I can see it moving). i.e. it has not reached its' destination.

3. The scene object which is the owner of the iso character returns isMoving == false in case #2 above. This makes sense, after onMoveComplete has fired, then the scene object should not be moving, but it is, I can see it moving.

 

Anyway, if you could clarify how I should be using onMoveComplete, it would be appreciated.

 

cheers

All 4 Comments
Gio

Hi

 

Good to know you're working a new isometric game, I enjoyed Polyphemus :)

 

For your isometric characters you may want to use different events, such as onObjectReached

 

onMoveComplete fires whenever an object (i.e. any regular WADE SceneObject) stops moving as a result of calling object.moveTo() or object.stopMoving(). Even if it's only for a single frame, the event fires. When you set a destination for an isometric object, wade.iso first finds a path to go to that destination, then internally it calls object.moveTo() for each segment of the path. So after each segment, onMoveComplete fires (which is when the IsoCharacter behavior tells the object to move onto the next segment of the path).

 

Having said that, it may be a good idea to add an onDestinationReached event for the IsoCharacters in the next version of the plugin. At present you could achieve the same result by using onMoveComplete and then calling IsoCharacter.getNextDestination() to see if there are any more destinations in the queue (i.e. any more path segments). It returns null when there are no more segments.

Shri

Gio,

 

Thanks for the quick response

 

I tried what you suggested (leo is the isoCharacter)

leo.owner.onMoveComplete = function() {            console.log('on move complete');            console.log(leo.getNextDestination());            if (leo.getNextDestination() == null) {               console.log('do something here');            }        };

The console log is as follows:

on move complete
Object {x: 2, z: 2, hScore: 5, cameFrom: Object, gScore: 2…}
 
on move complete
Object {x: 7, z: 2, valid: true}

 

The do something here is never executed as the last on move complete returns a valid object from the getNextDestination() call.

 

Can you please clarify what I am seeing ?

 

thanks

Gio

Yes, I just checked and you are right - what I suggested wouldn't work.

 

To elaborate: it is the IsoCharacter behavior that manages the destinations (or path segments), and that sets the next destination to null when there are no more segments in the path. When onMoveComplete fires, the onMoveComplete function of the SceneObject is executed first, then the onMoveComplete function of the behaviors is executed. So in the onMoveComplete function of the object, the next destination hasn't been set to null yet.

 

In other words, we definitely need to add an onDestinationReached event. If you are moving towards an object (with goToObject) then you can use the onObjectReached event, but if you aren't moving towards an object, you are going to need this new type of event.

 

We are going to release wade.iso 1.1 soon, hopefully at the same time as wade 1.1, so probably before the end of the week (though I can't promise that just yet). The new version is going to have this event, as well as most of  the other requests that were made in different threads.

Shri

Gio,

 

Thanks for the clarification and update info.

 

cheers

Post a reply
Add Attachment
Submit Reply
Login to Reply