How do I do a moveTo to a moving object ?

  • Hello !

    I am using moveTo behavior from rex, there is the link : c2rexplugins.weebly.com/rex_moveto.html

    What I want is doing the moveTo to an object, but my object is moving. This part is working, the problem is I have a condition that test if the overlap is enterely and sometimes (very often to be honest ^^) my moveTo bug because it goes to the X/Y at the moment my button was pushed so it isn't entirely in it and my condition never goes

    I wonder if there is way to upgrade moveTo so it automaticly correct the path until he is overlapping.

    Regards

  • Rather than trigger it once on the button push just moveTo the object constantly so it updates the right location. Or you can use pathfinding to make your way to the object.

  • So you mean, at the moment I use my input i should do "button pushed" instead of pressed ? Yeah it could work but it change all the feeling of gameplay. I should try it to test if it is still good to play.

    I will consider learn to use pathfinding aswell x)

  • No you said pushed so I used pushed What I mean is don't just trigger it once because it will moveTo the x,y at the time it was pressed, you can use every tick to constantly moveTo the object position. If you want it to constantly moveTo the object after a button press you can toggle a variable, if pressed=yes then moveTo object.

  • Hello,

    since it's a scholar project I can't use plugins, behaviors & co (forbidden, unfortunatly ). So I need to find a new way to do the same thing as moveTo. I have tried pathfinder but it doesn't work like I want (it can't go to an exact x/y so I can't use it). So there is a way to do like a moveTo (for the movement I mean), because at the moment I am using " set position to object " so it just TP on the other object, which is kinda ugly and making no sense in my game.

  • If you don't want to code the movement then

    I think you could use Bullet behaviour.

    just set the angle towards the end position

    and set speed to zero once arrived.

    Cant try it as I am at work but I think it should be OK.

    [edit]: sorry just saw you cant use behaviours..... you will have to code it then.

    I suppose the school want you to use / learn trigonometry / Pythagoras for the angles and distances

  • Yep as above, you can also use set angle towards and then 'move forwards'. Did you mean that you can't use behaviour because pathfinding is a behaviour, only plugins right?

  • Well it is kinda working but with some bugs.

    First of all, the angle is setting well so it goes in the good direction.

    But, it change the start position, I don't know why.

    Then, it goes to X/Y but even if it match it just never stop (because it stop when it is totally overlapping the object it has to goes by.)

    Finally, since it's moving object, it goes to the X/Y at the moment I press the button, but it is not changing the X/Y in real time.

  • To have it constantly moving toward the object you'll need to do it every tick. Doing it once on the click of a button will move it to where the object was at the point the button was clicked.

  • As you can see on the screen below, I am doing an every tick, as sub event. So it just set the speed at 100 once, and then it should every tick set the angle of motion to the "case_bus" position. I think the problem comes from key pressed, but i have changed it to key down and the problem is same (even worse I would say).

    Btw, I have fixed the "tp" problem, was coming from my origin point that wasn't at the right place.

  • NetOne just saw ur edit, It's not that i can't use Behaviours, I just can't add new ones. I can only use the basics one of free version

  • Ok, I have worked on it. And fixed my bug (was also coming from origin pont, they were all bugued, kinda had to remake them all but now it's fine).

    The last thing is, if I do a " Key Down ", it is working but I want it to be a " Key Pressed ", but the problem with the pressed one is, if it's move it will not adapt the direction even with every tick because I am putting it as sub event (which I have to since the condition about the " top " " right " & co is important since it decide to which case the player will go.

    So I am wondering if there is a way to adapt this to Key Pressed (which I prefer, for the gameplay)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dreaa can you post a screen shot of the finished events for the custom MoveTo?

  • NetOne just saw ur edit, It's not that i can't use Behaviours, I just can't add new ones. I can only use the basics one of free version

    @dreaa I'm also trying to avoid using 3rd party plugins.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)