Commit 33729f32 authored by kgingras's avatar kgingras
Browse files

zero grav CC final touches

parent 05882b84
fileFormatVersion: 2
guid: 0f0f4be8d4f95364298925847611e558
timeCreated: 1454654769
guid: 2ddc76b9622f555498571728ecbe5d8b
folderAsset: yes
timeCreated: 1454917585
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 1e07a4b9fc0cd5a419ad848d4fa22545
folderAsset: yes
timeCreated: 1454917585
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7d3425a6c7317e048be11c2ff72db69e
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: Bip001
100002: Bip001 Head
100004: Bip001 L Calf
100006: Bip001 L Clavicle
100008: Bip001 L Finger0
100010: Bip001 L Finger01
100012: Bip001 L Finger02
100014: Bip001 L Finger1
100016: Bip001 L Finger11
100018: Bip001 L Finger12
100020: Bip001 L Finger2
100022: Bip001 L Finger21
100024: Bip001 L Finger22
100026: Bip001 L Finger3
100028: Bip001 L Finger31
100030: Bip001 L Finger32
100032: Bip001 L Finger4
100034: Bip001 L Finger41
100036: Bip001 L Finger42
100038: Bip001 L Foot
100040: Bip001 L Forearm
100042: Bip001 L Hand
100044: Bip001 L Thigh
100046: Bip001 L Toe0
100048: Bip001 L UpperArm
100050: Bip001 Neck
100052: Bip001 Pelvis
100054: Bip001 R Calf
100056: Bip001 R Clavicle
100058: Bip001 R Finger0
100060: Bip001 R Finger01
100062: Bip001 R Finger02
100064: Bip001 R Finger1
100066: Bip001 R Finger11
100068: Bip001 R Finger12
100070: Bip001 R Finger2
100072: Bip001 R Finger21
100074: Bip001 R Finger22
100076: Bip001 R Finger3
100078: Bip001 R Finger31
100080: Bip001 R Finger32
100082: Bip001 R Finger4
100084: Bip001 R Finger41
100086: Bip001 R Finger42
100088: Bip001 R Foot
100090: Bip001 R Forearm
100092: Bip001 R Hand
100094: Bip001 R Thigh
100096: Bip001 R Toe0
100098: Bip001 R UpperArm
100100: Bip001 Spine
100102: Bip001 Spine1
100104: Bip001 Spine2
100106: Body_01
100108: //RootNode
400000: Bip001
400002: Bip001 Head
400004: Bip001 L Calf
400006: Bip001 L Clavicle
400008: Bip001 L Finger0
400010: Bip001 L Finger01
400012: Bip001 L Finger02
400014: Bip001 L Finger1
400016: Bip001 L Finger11
400018: Bip001 L Finger12
400020: Bip001 L Finger2
400022: Bip001 L Finger21
400024: Bip001 L Finger22
400026: Bip001 L Finger3
400028: Bip001 L Finger31
400030: Bip001 L Finger32
400032: Bip001 L Finger4
400034: Bip001 L Finger41
400036: Bip001 L Finger42
400038: Bip001 L Foot
400040: Bip001 L Forearm
400042: Bip001 L Hand
400044: Bip001 L Thigh
400046: Bip001 L Toe0
400048: Bip001 L UpperArm
400050: Bip001 Neck
400052: Bip001 Pelvis
400054: Bip001 R Calf
400056: Bip001 R Clavicle
400058: Bip001 R Finger0
400060: Bip001 R Finger01
400062: Bip001 R Finger02
400064: Bip001 R Finger1
400066: Bip001 R Finger11
400068: Bip001 R Finger12
400070: Bip001 R Finger2
400072: Bip001 R Finger21
400074: Bip001 R Finger22
400076: Bip001 R Finger3
400078: Bip001 R Finger31
400080: Bip001 R Finger32
400082: Bip001 R Finger4
400084: Bip001 R Finger41
400086: Bip001 R Finger42
400088: Bip001 R Foot
400090: Bip001 R Forearm
400092: Bip001 R Hand
400094: Bip001 R Thigh
400096: Bip001 R Toe0
400098: Bip001 R UpperArm
400100: Bip001 Spine
400102: Bip001 Spine1
400104: Bip001 Spine2
400106: Body_01
400108: //RootNode
4300000: Body_01
9500000: //RootNode
13700000: Body_01
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
optimizeGameObjects: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
animationCompression: 1
animationRotationError: .5
animationPositionError: .5
animationScaleError: .5
animationWrapMode: 0
extraExposedTransformPaths: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: .00999999978
meshCompression: 0
addColliders: 0
importBlendShapes: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 0
tangentSpace:
normalSmoothAngle: 60
splitTangentsAcrossUV: 1
normalImportMode: 0
tangentImportMode: 1
importAnimation: 1
copyAvatar: 0
humanDescription:
human: []
skeleton: []
armTwist: .5
foreArmTwist: .5
upperLegTwist: .5
legTwist: .5
armStretch: .0500000007
legStretch: .0500000007
feetSpacing: 0
rootMotionBoneName:
hasTranslationDoF: 0
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 1
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f3b97c04b16b432478934d292afa6cc1
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9666413be1a1d004297a1ea4af24125d
folderAsset: yes
timeCreated: 1454917585
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dd57fea2d38633a42be0ca58ae57c683
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 24a641a25f89b1a49bc36a8f2f406aaa
folderAsset: yes
timeCreated: 1454917585
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 526f476039ebee544874f76e9bc8b3ce
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: c4772712b065971448eb46d50d6e9a7b
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: -1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b7962e4d69e932c498775fe53fe19305
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 1
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 0
textureType: 1
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class Level {
public Mesh mesh;
private bool drawDebugMesh;
private Path path;
private Face[] faces;
private int[] triangles;
private Vector3[] vertices;
private Vector2[] uvs;
public Level (int len, float startRadius, float maxRadius, float partLength, int sides, bool draw) {
float startTime = Time.realtimeSinceStartup;
drawDebugMesh = draw;
mesh = new Mesh ();
uvs = new Vector2[len * sides];
path = new Path (len, startRadius, maxRadius, partLength, drawDebugMesh);
faces = GenerateFaces (path, sides, drawDebugMesh);
vertices = GenerateVertices (len, sides, faces);
triangles = GenerateTriangles (len, sides, vertices);
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uvs;
mesh.RecalculateNormals ();
mesh.Optimize ();
Debug.Log ((Time.realtimeSinceStartup - startTime) * 1000 + "ms for generating level");
}
private Face[] GenerateFaces (Path p, int sides, bool drawDebugMesh) {
Face[] f = new Face[p.length];
for (int n = 0; n < f.Length; n++) {
f[n] = new Face (p.radius[n], sides, p.centerPoints[n], p.centerPointNormals[n], p.faceRotation[n], drawDebugMesh);
if (n != 0 && drawDebugMesh) {
for (int i = 1; i < f[n].vertices.Length; i++) {
Debug.DrawLine (f[n].vertices[i], f[n - 1].vertices[i], Color.red, 600);
}
}
}
return f;
}
private Vector3[] GenerateVertices (int len, int sides, Face[] face) {
Vector3[] v = new Vector3[len * sides];
for (int n = 0; n < face.Length; n++) {
for (int i = 0; i < sides; i++) {
v[n * (sides) + i] = face[n].vertices[i];
}
}
return v;
}
private int[] GenerateTriangles (int len, int sides, Vector3[] verts) {
int[] tris = new int[verts.Length * 6];
for (int n = 0; n < len - 1; n++) {
for (int i = 0; i < sides; i++) {
if (i != sides - 1) {
tris[n * (sides) * 6 + i * 6] = (n * sides) + i;
tris[n * (sides) * 6 + i * 6 + 1] = (n + 1) * sides + i;
tris[n * (sides) * 6 + i * 6 + 2] = (n + 1) * sides + 1 + i;
tris[n * (sides) * 6 + i * 6 + 3] = (n * sides) + i;
tris[n * (sides) * 6 + i * 6 + 4] = (n + 1) * sides + 1 + i;
tris[n * (sides) * 6 + i * 6 + 5] = (n * sides) + i + 1;
} else {
tris[n * (sides) * 6 + i * 6] = (n + 1) * sides - 1;
tris[n * (sides) * 6 + i * 6 + 1] = sides * (n + 1) + i;
tris[n * (sides) * 6 + i * 6 + 2] = sides * (n + 1);
tris[n * (sides) * 6 + i * 6 + 3] = (n + 1) * sides - 1;
tris[n * (sides) * 6 + i * 6 + 4] = sides * (n + 1);
tris[n * (sides) * 6 + i * 6 + 5] = n * sides;
}
}
}
return tris;
}
public struct Path {
public int length; // Length (in circles) of the tunnel
public float[] radius; // The radius of each circle
public Vector3[] centerPoints; // The center point of each circle
public Vector3[] centerPointNormals; // The normal of each circle
public Vector3[] faceRotation;
public Path (int len, float startRadius, float maxRadius, float partLength, bool drawDebugMesh) {
length = len;
radius = new float[length];
centerPoints = new Vector3[length];
centerPointNormals = new Vector3[length];
faceRotation = new Vector3[length];
radius[0] = startRadius;
centerPoints[0] = Vector3.zero;
faceRotation[0] = Vector3.zero;
for (int n = 1; n < length; n++) {
radius[n] = startRadius;
//radius[n] = radius[n - 1] + Random.Range (-0.5f, 0.5f);
faceRotation[n] = new Vector3 (faceRotation[n - 1].x + Random.Range (-0.2f, 0.2f), faceRotation[n - 1].y + Random.Range (-0.2f, 0.2f), 0);
centerPoints[n].x = partLength * Mathf.Sin (faceRotation[n].y) * Mathf.Cos (faceRotation[n].x) + centerPoints[n - 1].x;
centerPoints[n].y = partLength * Mathf.Cos (faceRotation[n].y) * Mathf.Sin (faceRotation[n].x) + centerPoints[n - 1].y;
centerPoints[n].z = partLength * Mathf.Cos (faceRotation[n].x) * Mathf.Cos (faceRotation[n].y) + centerPoints[n - 1].z;
if (drawDebugMesh) {
Debug.DrawLine (centerPoints[n - 1], centerPoints[n], Color.yellow, 600);
}
}
for (int n = 0; n < length - 1; n++) {
centerPointNormals[n] = centerPoints[n] - centerPoints[n + 1];
}
}
}
public struct Face {
public Vector3[] vertices;
public Face (float r, int sides, Vector3 centerPoint, Vector3 centerPointNormal, Vector3 rotation, bool drawDebugMesh) {
vertices = new Vector3[sides];
float angle = 2 * Mathf.PI / sides;
Vector3 normalized = centerPointNormal;
Vector3 ortho1 = Vector3.up;
Vector3 ortho2 = Vector3.right;
Vector3.OrthoNormalize(ref normalized, ref ortho1, ref ortho2);
for (int n = 0; n < sides; n++) {
//vertices[n].x = centerPoint.x + r * Mathf.Sin(n * angle);
//vertices[n].y = centerPoint.y + r * Mathf.Cos(n * angle);
//vertices[n].z = centerPoint.z;
vertices[n] = centerPoint + r * Mathf.Sin(n * angle) * ortho1 + r * Mathf.Cos(n * angle) * ortho2;
//vertices[n] = vertices[n] - Vector3.Dot (vertices[n] - centerPoint, normalized) * normalized;
if (n != 0 && drawDebugMesh) {
Debug.DrawLine (vertices[n], vertices[n - 1], Color.red, 600);
}
if (n == sides - 1 && drawDebugMesh) {
Debug.DrawLine (vertices[n], vertices[0], Color.red, 600);
}
}
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 83c8ae6ee5d4f61469a343121945c63c
timeCreated: 1454808870
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -48,20 +48,21 @@ public class CapsuleController : MonoBehaviour {
void FixedUpdate () {
Ray ray;
RaycastHit hit;
RaycastHit forwardHit;
if (Physics.Raycast(transform.position, -myNormal, out hit, Mathf.Infinity)){ // use it to update myNormal and isGrounded
if(Physics.Raycast(transform.position, myForward, out forwardHit, 1f)){
if(forwardHit.distance < hit.distance){
isGrounded = forwardHit.distance <= distGround + deltaGround;
surfaceNormal = forwardHit.normal;