Creating a 3D effect with GDevelop?

Hi,
I am trying to create a floor that is moving towards the player. Like this:
image

I start by setting a timer and adding rows and then resetting the timer. Every row consists of two rows like this one:

image

After that I add a force in 90° with a permanent speed. The hing is that the speed accelerates, so the rows get appart when reaching the bottom of the scene. I have also tried adding a scale to make the rows bigger the closer the bottom they reach. Thats also causing me problems since the center point don’t seem register in the middle. I have edited the center point of the sprite to the middle, but the instance insits on scaling out to the right of the scene. What can be causing these problems?

Thanks

Farre

Either use instant force always, or permanent force with a Trigger once. Otherwise, the speed keeps increasing (acceleration).
If the scaling action is based on the upper-left corner, you’ll have to adjust the position of your sprites when scaling. Have you tried moving the origin point? Some actions use that point.

Thanks,
The Trigger once made the objects move with a constant speed, so that worked fine. But scaling the rows and keeping them aligned (in both x and y) seems to be more advanced than I first thought. I think I’ll have to choose a simpler solution for the floor. Maybe I’ll use dots or simple lines moving towards the player.

//Farre

After scaling, you simply may change position at each frame in order to get them aligned

Tarsio, it’s more complicated than that. Since I need to scale them on both x and y axes they get thicker and start to overlap each other when getting closer to the bottom of the scene. If I make them move faster to prevent that they will have to have a distance between each other in the beginning of the scaling process. I am a noob and I think this might be to complicated for me. I have a tight deadline to finish this game, so sadly I need to keep it simple.

Thanks for helping me out :slight_smile:

I see the problem. Look at this :wink::
https://s3-eu-west-1.amazonaws.com/gd-games/game-a0e2f5bd-70c6-427c-ad3f-aeb653e65b31/index.html

Move the purple square (it’s not perfect because sprites are not horizontal symmetric. You need horizontal simmetrice images, since alignement is central!)

1 Like

Here is my code.

The ingredient you need is math. Sum of a power series.

1 Like

Wow, really impressive work Tarsio! I only have very basic math skills so I don’t understand how you made it. I’ll see if I can reproduce your code and make it work as I wish.

Thanks

Farre

1 Like

You are welcome. Ask me if you have some doubt in my code

Hello again,
Thanks Tarsio, I managed to reproduce your code and create the floor as a “still image” on the scene. I also managed to center the floor by adding 50 and 400 to the Y and X position.
Now I am trying to animate the floor as a loop. Like repeating your code forever, but now I am stuck.
Here is my attempt:

It would be great if you could help me to find a way to make the floor move.

Thanks

Farre

With the FloorTimer it seems to me little complicated, I think it is better to change approach. The main problem is that Timer event is discrete.
Using just the moving of the pointer:

http://s3-eu-west-1.amazonaws.com/gd-games/game-3e5e1390-dd8c-476c-ace1-32d3a4f31a68/index.html

Ok, thanks! That is just what I was trying to do, but without the pointer. Why do I need a pointer? I just want a scrolling background. How do I make the floor move without a pointer (the pink dot?). My goal is to have things moving along with the floor, at the same speed as the floor and letting the user catch them with an object (an image of a hand).

/Farre

Also,
I can’t make your latest example work. The scene is blank when I play it. I assumed that Pointer is an object (graphics) so I made a dot in piskel and named it Pointer. Is that correct and does my code below look good?

Did you create an istance of the Pointer object in the scene?
The Pointer is not really really necessary, but it is a good solution, since you could apply a force on it. You have to hide it, for making it invisible

Actually just before you wrote your reply question I put an instance of the Pointer in the scene and now it will run, but only once. It seems like that the reason is that I put it in the “At the beginning of the scene”-event. I tried to create the Instance as a separate event before that but it didn’t work. This is how it looks like right now. You can see the small black pointer at the bottom of the scene. My version will only run once, so I guess I have to repeat the creation of the pointer to make it loop. And also delete the pointer when it is out of the scene?

Farre

in the second condition you typed “Variable(1)” instead of “Variable(i)”

Wow, now it works perfectly!! Thank you very much Tarsio!!

/Farre

Here is my final code if anybody wants to download it:

http://posh.se/gdevelop/scrollingfloor.zip

1 Like

Hello again,
I’m back :slight_smile: I thought that it would be easy to modify the code but I was wrong. Now I’m trying to add objects on both sides of the floor. In my case images of shelves, pretty much as in the image below. The problem is that I just can’t figure out which parameters to change to alter, direction and scale of the shelves on the side of the floor. I have tried to change the coeff, i, direction of pointer, the numbers in the “Change position” and “change scale” commands but whatever I do everything goes totally weird. Would it be possible to get some kind of help in how to alter position and directions of the objects on the scene?

Thanks

Farre

@Tarsio, I also wonder what happens with the Pointer after a while. As it seems the Pointer.Y() value is like an infinite loop that just keeps growing. Is that ok considering memory usage? Should I reset it in some way?

Since the Pointer.Y() value keeps growing I don’t understand how it is possible for the maths below to work (obviously it does). As far as I (mis)understand the code, the height of the floor object should be the power of coeff and id plus the increasing value of Pointer.Y divided with 20. For example 1.24 ^ -23 + 2000/20, but that isn’t correct. The height of the floor is never more than 200 pixels. This is really confusing.

pow(Variable(coeff), Floor.Variable(id)+Pointer.Y()/20)

Hi,

  • You are forgetting the brackets: 1.24 ^ (-23 + 2000/20)
  • Yes, the pointer keep going to infinity, but I don’t think that this take a lot of memory. A big number is nothing compared to rendering of object. You may reset it if you want, but I think this is a minor issue. The important thing, is deleting floors outside screen, which is already done.
  • For the bookshelf, this is a nice idea, and it is not so different from the floor. Before awsering I need to know: do you need many other objects with this perspective? How the game works?