Jump to content

[lua] slider/platform script


Skrakle
 Share

Recommended Posts

Here's another version of the platform.lua with additional options.

 

- The entity waypoint has been replaced with multiple Vec3's allowing multiple waypoints.

- Looping. (clockwise or ping-pong)

- Pause timer between waypoints. (in milliseconds)

- Randomize starting waypoint.

 

Here's a video demonstration of the script in action:

https://www.youtube.com/watch?v=-1Q4qAcW40k&feature=youtu.be

platform_slider.lua

post-14340-0-37382600-1432900913.jpg

  • Upvote 3
Link to comment
Share on other sites

That's great.

About workflow i would use Pivots instead of having to enter values : it's a old programmers hard and long way of making games laugh.png

Instead of having to gather the coordinates in the editor each time, you place pivots that are visible in the editor so you have instant feedback where your platform will move smile.png, and you just bind pivots to your script with drag and drop.

Stop toying and make games

Link to comment
Share on other sites

I agree, it definitely would make it easier to setup while editing but that's a matter of preference, some people need to see things visually more than others. For me, it's a matter of memory and performance, the choice was Initializing a Pivot object with tons of properties and methods vs a single Vec3. smile.png

Link to comment
Share on other sites

the choice was Initializing a Pivot object with tons of properties and methods vs a single Vec3.

A pivot is an empty object and initialisation is just done one time at game start on the entity start() function, so i don't think it is some optimisation needed here.

Benefit of pivot is having having game level modifications is also more easy as you just move pivots visually, and you can't loose lot of time gathering coordinates and enter them if you had a big level with thousand platforms.

It would be anti level designer productivity laugh.png

Stop toying and make games

Link to comment
Share on other sites

A pivot is an empty object and initialisation is just done one time at game start on the entity start() function, so i don't think it is some optimisation needed here.

If you read my previous post again, you'll notice that i'm not only talking about speed optimization but memory as well which is my point.

 

As for the pivot being an empty object, that is completely wrong, once initialized, there are objects in it are automatically initialized as well whether you're using them or not and will use extra (and unnecessary) memory... rolleyes.gif

 

You should do some testing before making assumptions like that.

 

 

Benefit of pivot is having having game level modifications is also more easy as you just move pivots visually, and you can't loose lot of time gathering coordinates and enter them if you had a big level with thousand platforms.

It would be anti level designer productivity laugh.png

It's like i said, there are people (such as you obviously) that need to see such things visually to be more productive, i don't.

 

 

Edit:

- I initialized 20000 Vec3s and it took about 1mb of memory

- I initialized 20000 Pivots (without using or modifying them, just a simple Pivot::Create) and it took about 88mb.

 

I rest my case.

Edited by Skrakle
  • Upvote 1
Link to comment
Share on other sites

- I initialized 20000 Pivots (without using or modifying them, just a simple Pivot::Create) and it took about 88mb.

The problem is within the Pivot object in LE3 to take so much memory, compared to a really empty "node" object you can find in JME3. I doubt i'll have 2000 pivot in a scene level, specially when it's not a open world.

Stop toying and make games

Link to comment
Share on other sites

It looks like a pivot entity takes up 4616 bytes. It has the full functionality of all entities, so it is fairly heavyweight in great numbers.

 

In the above example using them will make absolutely no difference. Just do what you feel most comfortable with.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Yeah i know 20000 pivots seems extreme as a test, that was merely to demonstrate the consumption factor. Even if it's insignificant, it still good practice, especially if one day, the engine ever goes to console.

Is it good practice to design systems that are harder to use, in the name of imaginary optimizations that aren't really there? That's a good design lesson for you to learn.

 

25.jpg

 

Personally, I suspect you really feel more comfortable with the Vec3 design, which is fine.

 

So what if your game is heavily dependent on Pivots like ours?
Do the math. If your memory consumption gets into the hundreds of megabytes, you may have a problem. I calculate you can support about 500 houses with just 100 mb memory, so that does not seem like it will be your bottleneck..

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...