Wintermute Engine > Technical forum

The illusion of vehicle movement across the scene (on the X-axis)

<< < (4/4)

Indra Anagram:

--- Quote from: Mnemonic on November 25, 2017, 01:05:55 PM ---Basically you'd need just one script, that would move it's owner entity by decreasing its X position, and if X is lower than some threshold, it would increase it again and repeat the process.

--- End quote ---


--- Quote from: anarchist on December 16, 2017, 10:43:07 PM ---What you want is the entities to start on the start position, move right and then, when they have reached a predefined position on the right they appear on the left.

--- End quote ---


--- Quote from: eborr on December 02, 2017, 11:48:51 PM ---Not wishing to sound harsh but all you do is to reset the x,y coordinnates for each object within a loop.

--- End quote ---

Hey guys!

Sorry, but I still don't understand how to make your script work for multiple tree entities. I tried to adjust it for several trees, and in the end it always causes errors and undesirable behavior. Please, if you know how the script should work, tell me what's the solution for several entities.

This script could be good for clouds too, btw.

THANK YOU for your friendly attitude and help!

anarchist:
Lets take one of the scripts you showed as example and modify it. I will add comments in the code, please read carefully and understand what we are doing, DO NOT simply copy paste the code.


--- Code: WME Script ---//These are the STARTING POSITIONS of your entitiestreebg1.X = 0;treebg2.X = 100; var amountOfLoops = 5000;var loopsSoFar = 0;//This is the maximum X coordinate for ALL your entities.//More specifically, this is the "edge" of your screen on the right.//Whenever an entity reaches this X coordinate, you move it to the//FAR LEFT (meaning X = 0).var maximumX = 1200; //We will perform 5000 loops.while(loopsSoFar < amountOfLoops){        treebg1.X = treebg1.X + 1;        if(treebg1.X == maximumX)        {                treebg1.X = 0; //Move this tree to the far left.        }                treebg2.X = treebg2.X + 1;        if(treebg2.X == maximumX)        {                treebg2.X = 0; //See here? We move the tree to the FAR LEFT (X = 0), NOT to its starting coordinate!        }                //etc. etc.        //You can repeat the same for all entities.        //There could be a smarter way to do this using arrays but for now try the simple version        //until you become better in programming.                //We sleep for 10 ms and we will loop 5000 times.        //This means this whole animation will take 5000 X 10 ms, meaning 50000ms.        //You can adjust the amount of loops depending on how long you want the animation to take.        //If you adjust how long the Sleep() command takes, you will in result adjust how fast the entities move.        Sleep(10);        //Increment (add one) loops counter so that the loop ends at some point. There are other ways to do it        //i.e. catch the ESCAPE key press and change a global variable, but for now try the simple way.        loopsSoFar = loopsSoFar + 1;} 
I have not tested this code so if it produces errors let us know which errors appear, or better yet try to solve them yourself first  ;)

What I believe you were missing is that each entity, after it reaches the far right of the screen, it should move to the far left, NOT its starting position. This will work, because, even though the "max x" of each entity is the same and the far left position is always 0, each entity starts on a different X, therefore it will take each entity a different amount of time to reach the far right X coordinate.

Indra Anagram:
Hi anarchist!


--- Quote from: anarchist on January 13, 2018, 05:43:12 PM ---I have not tested this code so if it produces errors let us know which errors appear

--- End quote ---

Well, I did paste your code in scene_init.script after reading your helpful comments and guess what? No errors were identified in the debug. FANTASTIC!  ::thumbup

However, I keep getting this behavior from first tree entity (
--- Quote ---treebg1.X = 0;
--- End quote ---
, remember?):

https://ibb.co/gvUr96

You see? First treebg2 entity appears in the FAR LEFT (no problem with that) and nearly a second later treebg1 emerges from nowhere.


--- Quote from: anarchist on January 13, 2018, 05:43:12 PM ---, or better yet try to solve them yourself first  ;)

--- End quote ---

In the attempt to solve this issue on my own I changed the starting x coordinate of the car entity, however the result turned out to look even more unnatural: first we see both tree entities frozen in the FAR LEFT edge and the car entity drives in to its SkipTo point from the FAR RIGHT edge and finally trees start moving like they should  :(

My question is -
Is there a way to start the scene with this FAR LEFT edge hidden somehow from our view? Is it possible to shift the "view" a bit to the right in order to conceal the starting points of the trees? Please tell me what you think about this!

This way no one will notice treebg1 teleportation))

Here are the scene files for your kind consideration. This way we both will see what the issue is with those tree entities.

My background image is 2400 X 600 and the scene "view" is 800 X 600. Any ideas about shifting the "view" from the default FAR LEFT background edge to the right?

anarchist, THANK YOU for your patience and knowledge! I guess it is difficult to understand things that I try to express sometimes (like with this last "view" question). Maybe we perceive the problem from different angles - logical (you) and visual (me). Will really have to reinvent my mind to acquire a programming mind type lol.

Navigation

[0] Message Index

[*] Previous page

Go to full version