How do I do a moveTo to a moving object ?

Get help using Construct 2

Post » Wed Feb 01, 2017 4:02 pm

Message: dreaa can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hello !

I am using moveTo behavior from rex, there is the link : http://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
B
5
Posts: 30
Reputation: 291

Post » Wed Feb 01, 2017 5:42 pm

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.
B
46
S
15
G
73
Posts: 2,027
Reputation: 43,461

Post » Wed Feb 01, 2017 6:43 pm

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)
B
5
Posts: 30
Reputation: 291

Post » Wed Feb 01, 2017 8:22 pm

No you said pushed so I used pushed :D 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.
B
46
S
15
G
73
Posts: 2,027
Reputation: 43,461

Post » Wed Feb 08, 2017 10:48 am

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.
B
5
Posts: 30
Reputation: 291

Post » Wed Feb 08, 2017 11:03 am

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
...
B
42
S
21
G
7
Posts: 260
Reputation: 7,683

Post » Wed Feb 08, 2017 11:09 am

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?
B
46
S
15
G
73
Posts: 2,027
Reputation: 43,461

Post » Wed Feb 08, 2017 11:24 am

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.
B
5
Posts: 30
Reputation: 291

Post » Wed Feb 08, 2017 11:30 am

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.
B
46
S
15
G
73
Posts: 2,027
Reputation: 43,461

Post » Wed Feb 08, 2017 1:26 pm

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.

Image
B
5
Posts: 30
Reputation: 291

Next

Return to How do I....?

Who is online

Users browsing this forum: ladjuric, plinkie, Syazanie Amirin and 3 guests