Yoshi's Island eggs

Get help using Construct 2

Post » Wed Jun 17, 2015 6:36 pm

@pcfernandesjr
In that example just adding another egg works fine to add it to the end. If you want the eggs to be ordered in the way you collect them you could do something like this to assign a number to the eggs you collect:
Code: Select all
global index=0

on player collided with egg
egg is not collected
for each egg
--- egg: set collected to true
--- egg: set num to index
--- add 1 to index


Then change the "for each" in the example to

egg is collected
for each egg ordered by egg.num ascending
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254

Post » Wed Jun 17, 2015 9:43 pm

@R0J0hound

Yeah, I though about something like you suggested on the code field. But I just got stuck there. :P

I will try edit my code. Hope it works fine.

Cheers and thanks for the help!
B
12
S
6
G
3
Posts: 101
Reputation: 3,930

Post » Wed Jun 17, 2015 10:18 pm

Hi @R0J0hound!

I followed your suggestion, but there is one problem. The eggs are overlapping each other, instead of positioning one behind another. Maybe this is something about the variables involved on LERP, or maybe the 'set target_time' part?

Just to clarify, here is my code (the hidden bit is the 'while' part, forgot to expand it):

Image

Cheers!
B
12
S
6
G
3
Posts: 101
Reputation: 3,930

Post » Wed Jun 17, 2015 10:45 pm

R0J0hound wrote:Hi, I got it working so that the eggs stay a certain time delay behind the player.

https://dl.dropboxusercontent.com/u/542 ... _time.capx

I changed a few things to get it to work. First in addition to x and y I also save the time. This is so I can find the saved position just before and after a certain time. If the first egg would is half a second behind the player then I would find the positions closest to time-0.5. After that I can then interpolate between the positions with lerp. The send thing I change from the original is add to the front of the array instead of the back so I could trim off the excess with a set size.


Oh it just like replay system to me, a shadow copy. Excellent!
ImageImage
B
101
S
45
G
22
Posts: 772
Reputation: 21,468

Post » Thu Jun 18, 2015 4:53 am

@pcfernandesjr
Doesn't the original example do that too? Like alextro said it just positions the eggs where the player was a certain time in the past, so if the player stops they will all stack on him.

I don't have a solution to keeping the eggs from stacking. I've tried stopping time advancement when the player doesn't move, but then the eggs are just frozen in space.

One idea could be to think of the eggs as a chain attached to the player. So maybe leveraging the pin behavior to link them together and drop them with gravity and bounce them a bit.
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254

Post » Thu Jun 18, 2015 5:24 am

How made the player can look to the follower? I need add this in my game, and when the player look to front of follower, can press an button to see the follower state or do dialogs. Like Pokémon Yellow.
My Bitcoin address: 1NG9VKTZzA3patBrWySA4qRWcuKyYkhtfc
B
23
S
7
G
4
Posts: 320
Reputation: 3,839

Post » Thu Jun 18, 2015 5:28 am

How press the button and start the rest i know, but i don't know how made the player can look to follower, and trigger actions if the player is in front of follower (looking him). Thanks in advance.
My Bitcoin address: 1NG9VKTZzA3patBrWySA4qRWcuKyYkhtfc
B
23
S
7
G
4
Posts: 320
Reputation: 3,839

Post » Thu Jun 18, 2015 5:50 am

This is an example of what I want to achieve. If anyone can help, this will be usefull for other people.
Image
Last edited by DaniellMesquito on Fri Jun 19, 2015 5:27 am, edited 1 time in total.
My Bitcoin address: 1NG9VKTZzA3patBrWySA4qRWcuKyYkhtfc
B
23
S
7
G
4
Posts: 320
Reputation: 3,839

Post » Thu Jun 18, 2015 12:18 pm

R0J0hound wrote:@pcfernandesjr
Doesn't the original example do that too? Like alextro said it just positions the eggs where the player was a certain time in the past, so if the player stops they will all stack on him.

I don't have a solution to keeping the eggs from stacking. I've tried stopping time advancement when the player doesn't move, but then the eggs are just frozen in space.

One idea could be to think of the eggs as a chain attached to the player. So maybe leveraging the pin behavior to link them together and drop them with gravity and bounce them a bit.


Hi @R0J0hound!

Yes, I expressed myself badly. The eggs indeed are supposed to overlap each other while they're idle. That is fine.

What happened is that they were overlapped while in movement. But this was due some mistake I did.

The issue now is that, for each egg that joins the line, the LERPing gets more and more screwed up. Here is the current code:

Image

If you want to take a look on the real thing running, I uploaded the demo on my dropbox:

https://dl.dropboxusercontent.com/u/129 ... index.html

Cheers!

DaniellMesquita wrote:This is an example of what I want to achieve. If anyone can help, this will be usefull for other people.
Image


Hi @DaniellMesquita, maybe you should do this:

have a way to check this before starting the following part of the code:

1-which direction your character is facing
2-if the x position of your character is greater or smaller (depending if the player will start walking left, or right.) than the x position of the follower

I think that should work, but as we can see I am not an specialist :P
B
12
S
6
G
3
Posts: 101
Reputation: 3,930

Post » Fri Jun 19, 2015 3:16 am

Sorry, I don't know what's amiss. Assuming my example is correct then yours should work if there is no typos.
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: varr and 4 guests