Jump to content
Skrakle

[lua] slider/platform script

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

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post
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

Share this post


Link to post

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

Share this post


Link to post
- 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.

Share this post


Link to post

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.

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

So what if your game is heavily dependent on Pivots like ours?

 

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

Share this post


Link to post

No, I actually meant the OP. That wasn't very clear. smile.png

 

Interesting discussion, anyways.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...