2
2012
Flying inside 3D Perlin Cave
Never-ending perlin caves to explore!
Current features:
– Unlimited cave flying
– Plasma(?) cannon
– Moving around with keys (wasd/arrow keys)
– Shooting with mousebutton
– 1 stone material
– added: light source, shooting sound, block destruction, basic collision detection for movement (not for player destruction yet)
I’m thinking something like this, maybe another version with the cave in 2.5D and view from side:
Scramble C64 (Play Online: http://c64s.com/game/689/scramble/ | Video: http://www.youtube.com/watch?v=qqBVDX3xy0M )
Webplayer:
http://unitycoder.com/upload/demos/UnlimitedPerlinCaves3D1/
PerlinCaveTile.cs (attach this to empty game object, then assign the block prefab to it
using UnityEngine;
using System.Collections;
public class PerlinCaveTiles : MonoBehaviour {
public int width=16;
public int height=16;
public float fireRate = 0.5f;
private float nextFire = 0.0f;
public float noiseScale=11.5f;
public float depthNoiseScale=1.0f;
private float z=0.0f;
// private float worldy=0.0f;
private float value;
public float holeThreshHold=0.2f;
public GameObject block; // default block
private Perlin perlin;
Perlin p = new Perlin();
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Time.time > nextFire)
{
CreateChunk();
nextFire = Time.time + fireRate;
}
}
void CreateChunk()
{
// generate initial map`/wall?
// create map array
//var n:int=0;
for (int y = 0;y<height;y++)
{
Instantiate(block, transform.position+new Vector3(0,y,0), transform.rotation);
Instantiate(block, transform.position+new Vector3(width,y,0), transform.rotation);
}
for (int x = 0;x<width;x++)
{
Instantiate(block, transform.position+new Vector3(x,0,0), transform.rotation);
Instantiate(block, transform.position+new Vector3(x,height,0), transform.rotation);
}
for (int y = 1;y<height;y++)
{
for (int x = 1;x<width;x++)
{
value = p.Noise(x*noiseScale,y*noiseScale,z*depthNoiseScale); // default
if (value>holeThreshHold)
{
Instantiate(block, transform.position+new Vector3(x,y,0), transform.rotation);
}
}
}
z++;
}
}
BlockMover.cs (temporary script for moving the blocks.. attach to block prefab)
using UnityEngine;
using System.Collections;
public class BlockMover : MonoBehaviour {
float speed = 3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(-Vector3.forward*speed*Time.deltaTime, Space.World);
if (transform.position.z < -17)
{
Destroy (gameObject);
}
}
}
Related Posts
9 Comments + Add Comment
Leave a comment to wolga
Recent posts
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by













Any infomation about the source release?
Yeah! I’d love to see the source!
yes, its coming eventually, bit busy lately 🙂
and actually all that this does:
– if Mathf.Perlin() > threshold, then instantiate cube..
– move cubes in z axis, until behind camera, then destroy it
that makes it bit slow, should rather use custom meshes..(similar to voxel terrains)
Can’t wait! I’m interested to see how you’ve created 3D noise with unity’s mathf implementation.
hi! this looks very intresting! i would really need to know how you did it. could you please publish at least the scene you already have? i would be very thankful!! 🙂
added couple sources on the post (it would really need to be re-done, it starts to get too slow because of too many cubes, object pooling should be used also if use invidual cubes)
ooh, soo great! thank you very much!! 🙂
Error on the first script, ‘The type of Namespace ‘Perlin’ could not be found’ on lines 22 and 23. Any help?
Needs the “Perlin.cs” from this package:
https://www.assetstore.unity3d.com/en/#!/content/5141