3d terrains

5 replies to this topic

#1 Red_Block_Studios

Red_Block_Studios

GMC Member

• New Member
• 17 posts
• Version:GM8

Posted 06 August 2012 - 01:07 AM

What would be the most efficient way of making a characters Z dependent on the hill he's standing on because the way I figured out would require 50,000 lines of code. That way being the game checks the x and y of the character and sets the z based on that I.e.
If x = somevariable && y = somevariable {z = height at certain position on map }
• 0

#2 PoniesForPeace

PoniesForPeace

puzzling

• GMC Member
• 493 posts
• Version:GM:Studio

Posted 06 August 2012 - 01:54 AM

There are plenty of examples, most using much less than 50,000 lines of code.
• 1

#3 Gamer3D

Gamer3D

Human* me = this;

• GMC Member
• 1590 posts
• Version:GM8.1

Posted 06 August 2012 - 06:07 AM

Using a 2-dimensional array, a simple way would be:

z = height[floor(x), floor(y)];

If you want smoother transitions, use bilinear filtering or some other smoothing algorithm.
• 0

#4 Red_Block_Studios

Red_Block_Studios

GMC Member

• New Member
• 17 posts
• Version:GM8

Posted 06 August 2012 - 02:00 PM

Well the 50,000 would only be if I were to check it on every x and y possible in the game
• 0

#5 filulilus

filulilus

GMC Member

• GMC Member
• 928 posts
• Version:GM:Studio

Posted 06 August 2012 - 02:06 PM

```if x = 1 && y = 1 z = 10
else if x = 2 && y = 1 z = 9
else if x = 3 && y = 1 z = 10
....```

But seriously... do a better search, like PoniesForPeace said, there are a lot of examples with diffrent approches.
• 0

#6 Red_Block_Studios

Red_Block_Studios

GMC Member

• New Member
• 17 posts
• Version:GM8

Posted 06 August 2012 - 03:35 PM

Well I'm trying to do something I would actually understand lol
• 0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users