Melon Digger , Teraforming For Gmod

over the past week i decided to try my hand at creating a dynamic world ( like the one in the game ‘Wurm online’ ) that the player would be able to change as he played.
The point in doing this was mainly to see if it could be done, and with what limits could it be done on.
Now that i know how to do this i will probably recode it from scratch now that i know whats going on.
(its very sloppy right now but its still a really cool thing to mess around in :smiley: )

how this works :
you a melon …
you can left click to move the mesh world down
right click to move it up 0.o

it uses physicsfrommesh to create it
(this ^^^^^ is such a b****, you cant have more then like 348 vertexes at a time, and it wont collide with players)

notes: when a player joins he will download the original world mesh, and as you change it, it will update
(Ive been up every night with headaches just trying to understand what Ive code, like i said the codes very sloppy )

This is what it looks like in the game mode:

Here is a download link for the map/gamemode/code, make sure you put all the files where they need to go :
(let me know if this link works megaupload was freaking out a second ago)

My exiting thoughts are the following :
i really hope in the future we will be able to have large scale teraforming inside of gmod.
at the moment because of the source engin the game will crash if you have any more then 348ish vertexes
i guess a work around would be to create maybe 20 vertexes around where ever the player is and have it follow him as he walks, this would lead to unlimited map size, assuming you don’t have a shit ton of players.

look at the code, try to figure out whats going on, i tried to comment what i could but im a bit tired as i write this and still in shock that i got this to work

Now that i know how to go about this il probably rewrite the whole thing, il let you know when i do i guess.

let me know you thoughts, comments, reactions, and questions about this.

k bai


Also, is it just the single mesh that can only have 348 vertices? Or in total

the client side mesh that you see rendered can have a lot of vertexes before crashing, maybe around 10,000 or more, i cant remember the number i came around to.

its the server side mesh( physicsfrommesh) that can only use arround 348 of em at a time. (in total )

(i loled at teh quote)


Is it 348 per mesh, or is that the limit regardless of how many meshes you use?

bah he quotes me right befor i go back and edit it >:L
its in total, i tried creating another prop with different coordinates and it crashes

You’re late with that, Minecraft gamemodes have already proven it a few months ago :v:.

i a melon?

This is pretty cool - how did you solve some of the problems you were having originally?

The main problem i was having with physicsfrommesh was that the player could not collide with the mesh, only props would. When one of my friends was smashing a prop onto the mesh i got the idea of making the player into a melon like in the gamemode melon racer.
The other big problem i was having with physicsfrommesh is that you can only have a certain amount of physics vertexes on the map at one time. it ultimately lead to me scaling down the project.

Now that i have these problems solved im going to recode it from scratch in hopes to make the mesh huge.
My idea is if i create a small maybe 3x3 physicsfrommesh under the player as he moves, it would allow of a much bigger world.

To make the player collide with the “terrain” you could parent a prop on the player’s feet.

Does that actually work? I was under the assumption this would nullify collisions.

Child objects don’t have independent physics so if you parented a player to a prop it would screw up the player movement i’m sure and if you parented a prop to the player it doesn’t collide with anything.

It would be awesome if this worked on a larger scale - I’d love a proper Wurm style gamemode. A shame that this is the upper limit.

I have plans for making this on a large scale, it will just take me a bit of time to set it up.
Since i’m modeling it after the game play in wurm online; the data i need to store for the world alone is crazy.
Everything Ive ever coded really hasn’t needed to store as much as this would. In the past Ive just used glon and txt files to store stuff.
I’m thinking for this il probably have to set up an sql for it, witch will take me a little bit of time as Ive never done that before in lua.

This is cute :slight_smile:

I hope you don’t mind, but I’m going to attempt to learn from your code. I’m waiting to download, but this should be a great tutorial! Thank you!

I’ve had this idea for 4 years. fuck, someone FINALLY did it.

now if you make this a customizable gamemode with the option to choose different textures and/or create different meshes we won’t need source sdk anymore :smiley:

Did you try creating the mesh clientside AND serverside? It needs to be both for the player to collide properly…

I believe i tried that in the beginning, but now thinking about it i don’t know if i did it right. Ill do a quick test to see if that solves the problem.

[editline]20th March 2011[/editline]

No luck when setting it on both client and server.
The physics from mesh just pushes the player away like when you create a physics init from box and don’t set collision bounds.
Unless im forgetting to call something i don’t know about; physics from mesh doesn’t work on players :frowning:

This is how im calling it if you were wondering :
function ENT:Initialize()
self.Entity:GetPhysicsObject():EnableMotion( false )

Garry, if you could fix PhysicsFromMesh to work properly with players, that’d be awesome, I’d love you.