Solving the "move to" concept?

Does Corona have any sort of “Move To” functionality for objects at a constant speed? For example, you click somewhere on the screen (a listener is built in to sense where on the screen) and certain object(s) move to that point, assuming no other physical objects interfere with them.

A simple transition.to() routine, setting the object’s target X/Y value would seem to make sense. However, in my testing, this method presents two problems. First, since the transition library is time-based, the objects move to their target position slower or faster depending on the distance they are set to travel. Second problem, and more crucial, is that the objects involved in a transition seem to ignore physics, even if they’re set as physical bodies with dynamic behavior.

The first problem (varying “movement” speed) could probably be solved by using math… i.e. calculating the distance between the start X/Y and target X/Y, then adjusting the “time” parameter dynamically to ensure a basically consistent movement speed. I don’t see a packaged math function in Corona that calculates the distance between two points, but I’m sure it’s possible with some basic trigonometry (probably time to brush up on that stuff :slight_smile: )

The physics issue is more problematic. In my test environment, the user can select/deselect multiple objects, just like a typical strategy game might employ. Say there are 5 “soldiers” on the screen. The user can select any combination of them individually (and later with a drag-select box, I hope!). Then the user clicks on the screen to send them to that location. A transition.to() will send them there, but all physics are ignored until the transition is complete… in other words, the soldiers overlap each other as they reach near the target, then when they reach it, they sort of “bounce” away from each other because physics is restored at that point.

My ideal goal is to have the objects move near to the location clicked by the user. Since they are physical bodies, not meant to overlap, 5 of them obviously cannot occupy the exact same target location. I just want to send them roughly to that location… they can definitely end up in a little cluster or whatever, basically around that location, just not overlapping.

Any thoughts or ideas on this? Maybe this can generate some interesting solutions and concepts. :slight_smile:

Brent
[import]uid: 9747 topic_id: 2575 reply_id: 302575[/import]

REVISION:

After some further testing, it seems that physics are not completely ignored during the transition.to() routine. It seems that the moving soldiers only ignore each other (physically), but they interact with other physical objects in the scene.

Part of my test routine involves a separation between “selected” soldiers and “non-selected” soldiers, using DisplayGroups. When the user selects them, they are inserted into the selectedSoldiers display group (and removed from the original group, per Corona behavior). When the user deselects them, they are restored to the deselectedSoldiers group. Is it possible that this grouping method is causing problems with physics sensitivity? [import]uid: 9747 topic_id: 2575 reply_id: 7358[/import]

How on earth did you get them to work with other objects in a scene? I have some static objects on screen. For example I have some pillars on screen. I have an object/character that moves when you click somewhere on screen to that point. I want him to stop if he contacts one of the pillars and wait till I choose a point he can move to by clicking again.

At the moment all that happens is he moves right over the top of the pillars. Like you found it would pop to the side as if the physics suddenly clicks in at the end of the loop. (I am also using the transition to command.

Any help would be greatly appreciated.

Cheers

Mike R [import]uid: 9950 topic_id: 2575 reply_id: 9775[/import]

You can’t use transitions and physics together as they will start fighting each other.

You will need to move the actors with a force or impulse.

It seems though you may be trying to do too much with the physics and might need to programatically do movements and you only detect collisions using sensors. You then handle the collisions yourself.

Most games don’t use physics as it isn’t right for the task. Moving something like soldiers around would require AI and you would tell the object to go somewhere, it works out the route and reacts to Walls by avoiding them rather than bouncing off of them. [import]uid: 5354 topic_id: 2575 reply_id: 9803[/import]

I ended up using impulse. Currently I am just experimenting and trying out all kinds of things with no real purpose.

Cheers

Mike R [import]uid: 9950 topic_id: 2575 reply_id: 9808[/import]

Yeah experimenting is the correct way to do things.

Also for times based transitions you can use a function to calculate the time to move the distance and use that time. Then your character will always move the same speed. [import]uid: 5354 topic_id: 2575 reply_id: 9811[/import]