The illusion of vehicle movement across the scene (on the X-axis)
Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Pages: 1 [2]  All

Author Topic: The illusion of vehicle movement across the scene (on the X-axis)  (Read 4213 times)

0 Members and 1 Guest are viewing this topic.

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 68
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #15 on: January 13, 2018, 03:16:52 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.

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.

Not wishing to sound harsh but all you do is to reset the x,y coordinnates for each object within a loop.

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!
Logged
Owls are not what they seem...

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #16 on: January 13, 2018, 05:43:12 PM »

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
  1. //These are the STARTING POSITIONS of your entities
  2. treebg1.X = 0;
  3. treebg2.X = 100;
  4.  
  5. var amountOfLoops = 5000;
  6. var loopsSoFar = 0;
  7. //This is the maximum X coordinate for ALL your entities.
  8. //More specifically, this is the "edge" of your screen on the right.
  9. //Whenever an entity reaches this X coordinate, you move it to the
  10. //FAR LEFT (meaning X = 0).
  11. var maximumX = 1200;
  12.  
  13. //We will perform 5000 loops.
  14. while(loopsSoFar < amountOfLoops)
  15. {
  16.         treebg1.X = treebg1.X + 1;
  17.         if(treebg1.X == maximumX)
  18.         {
  19.                 treebg1.X = 0; //Move this tree to the far left.
  20.         }
  21.        
  22.         treebg2.X = treebg2.X + 1;
  23.         if(treebg2.X == maximumX)
  24.         {
  25.                 treebg2.X = 0; //See here? We move the tree to the FAR LEFT (X = 0), NOT to its starting coordinate!
  26.         }
  27.        
  28.         //etc. etc.
  29.         //You can repeat the same for all entities.
  30.         //There could be a smarter way to do this using arrays but for now try the simple version
  31.         //until you become better in programming.
  32.        
  33.         //We sleep for 10 ms and we will loop 5000 times.
  34.         //This means this whole animation will take 5000 X 10 ms, meaning 50000ms.
  35.         //You can adjust the amount of loops depending on how long you want the animation to take.
  36.         //If you adjust how long the Sleep() command takes, you will in result adjust how fast the entities move.
  37.         Sleep(10);
  38.         //Increment (add one) loops counter so that the loop ends at some point. There are other ways to do it
  39.         //i.e. catch the ESCAPE key press and change a global variable, but for now try the simple way.
  40.         loopsSoFar = loopsSoFar + 1;
  41. }
  42.  

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.
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 68
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #17 on: January 15, 2018, 03:18:21 AM »

Hi anarchist!

I have not tested this code so if it produces errors let us know which errors appear

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;
, 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.

, or better yet try to solve them yourself first  ;)

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.
« Last Edit: January 15, 2018, 03:44:57 AM by Indra Anagram »
Logged
Owls are not what they seem...
Pages: 1 [2]  All
 

Page created in 0.161 seconds with 17 queries.