How do I make the player always stand in the middle?

Get help using Construct 2

Post » Mon Feb 13, 2017 12:04 pm

In fact, just takes a minute. Here is.

https://www.dropbox.com/s/0sztlu023hvqx ... .capx?dl=0
Last edited by 99Instances2Go on Mon Feb 13, 2017 12:04 pm, edited 1 time in total.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Feb 13, 2017 12:04 pm

Message: LaurenceBedford can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
99Instances2Go wrote:With lerp.

https://www.dropbox.com/s/ihs2oe5hv11ap ... .capx?dl=0

End positions are not 'exact' now, but movement is smooth.
Speed depends distance.

Want a constant speed, use Moveto Plugin. I make you an example if needed.

do you have a capx for rptating the layout using lerp or delta time?
Image
B
28
S
15
G
12
Posts: 310
Reputation: 9,633

Post » Mon Feb 13, 2017 1:13 pm

I hate it when sprites will not do what I tell them lol!

OK so I set up a simple test and the reason it overshoots and wobbles is because of the acceleration and deceleration formula 8 directions uses. I played with those numbers and could get it close but not perfect and you want perfect apparently and wobbling is not an option.

So here is is a simple trick I use all the time using a blank sprite to stop a character sprite exactly where I want them.

You need a clone of your player sprite with no behaviors and place it where you want your player sprite to stop (in the middle for your game).

Here are the events:

Image

I have the player sprite set at 400 speed, 400 acceleration and 0 deceleration. That 0 deceleration keeps the sprite moving back to the center.

I set the speed to 600 when I release a direction key that way the player goes back faster than it moved away from center and when it overlaps the clone sprite it stops perfectly on center.

Make the clone invisible and you can use that to have your player return to a specific spot anywhere.

EDIT: I added in a Start Ignoring Input command to keep your user from clicking keys in rapid fashion that throws off the direction the player is traveling.

This may be a problem if your player is shooting and you are using arrow keys to shoot. You may need to use a different key for shooting.
Last edited by lamar on Mon Feb 13, 2017 7:03 pm, edited 1 time in total.
Banned User
B
28
S
7
G
58
Posts: 1,229
Reputation: 34,825

Post » Mon Feb 13, 2017 6:19 pm

@LaurenceBedford

You mean something like this ?
https://www.dropbox.com/s/fp0nz6u5ngudo ... .capx?dl=0

Do not ask me to do this with 8Directions. 2Many quirks.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Feb 13, 2017 6:46 pm

Side tip:
@lamar "Every tick" with an "ON..." event has no effect. Drop it and it will work the same way it did with it.
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Mon Feb 13, 2017 6:59 pm

GamerGon wrote:Side tip:
@lamar "Every tick" with an "ON..." event has no effect. Drop it and it will work the same way it did with it.


Oh I forgot to take those out when I was testing it. No you don't need the Every Tick in there and works fine.

I removed them so people are not confused.
Banned User
B
28
S
7
G
58
Posts: 1,229
Reputation: 34,825

Previous

Return to How do I....?

Who is online

Users browsing this forum: TRMG and 36 guests