Commit b724bec4 authored by kgingras's avatar kgingras
Browse files

first commit

parents
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
*.csproj
*.unityproj
*.sln
*.suo
*.log
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.pidb.meta
sysinfo.txt
*.DS_Store
\ No newline at end of file
using UnityEngine;
using System.Collections;
public class CapsuleController : MonoBehaviour {
public float gravityForce = 9.8f;
public float walkSpeed = 1.0f;
public float sensitivity = 4f;
public Vector3 myForward = Vector3.zero;
public Vector3 myRight = Vector3.zero;
float moveSpeed = 6; // move speed
float turnSpeed = 90; // turning speed (degrees/second)
float lerpSpeed = 10; // smoothing speed
bool isGrounded;
float deltaGround = 0.2f; // character is grounded up to this distance
float jumpSpeed = 10; // vertical jump initial speed
float jumpRange = 10; // range to detect target wall
private Vector3 surfaceNormal; // current surface normal
private Vector3 myNormal; // character normal
private float distGround; // distance from character position to ground
private bool jumping = false; // flag "I'm jumping to wall"
private float vertSpeed = 0; // vertical jump current speed
Vector3 moving = Vector3.zero;
Rigidbody rb;
// Use this for initialization
void Start () {
myNormal = transform.up; // normal starts as character up direction
// distance from transform.position to ground
distGround = transform.position.y - 0f;
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true; // disable physics rotation
}
// Update is called once per frame
void FixedUpdate () {
Ray ray;
RaycastHit hit;
if (Input.GetButtonDown("Jump")){ // jump pressed:
if (Physics.Raycast(transform.position, -myNormal, out hit, jumpRange)){ // wall ahead?
// JumpToWall(hit.point, hit.normal); // yes: jump to the wall
}
else if (isGrounded){ // no: if grounded, jump up
rb.velocity += jumpSpeed * myNormal;
}
}
if (Physics.Raycast(transform.position, -myNormal, out hit, Mathf.Infinity)){ // use it to update myNormal and isGrounded
isGrounded = hit.distance <= distGround + deltaGround;
surfaceNormal = hit.normal;
// thirdPersonScript.newNormal = surfaceNormal;
}
else {
isGrounded = false;
// assume usual ground normal to avoid "falling forever"
surfaceNormal = Vector3.up;
}
myNormal = Vector3.Lerp(myNormal, surfaceNormal, lerpSpeed*Time.deltaTime);
GetMovement();
AddGravity();
}
void Update(){
GetMouseLook();
}
void GetMovement(){
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
//forward and right adjusted based on the normal of the surface
myForward = Vector3.Cross(transform.right, myNormal);
myRight = Vector3.Cross(-transform.forward, myNormal);
//adjust the rotation of the character based on the normal.
Quaternion targetRot = Quaternion.LookRotation(myForward, myNormal);
transform.rotation = Quaternion.Lerp(transform.rotation, targetRot, lerpSpeed*Time.deltaTime);
Vector3 targetVelocity = myForward * v + myRight * h;
targetVelocity *= walkSpeed;
Vector3 velocity = rb.velocity;
Vector3 velocityChange = (targetVelocity - velocity);
rb.AddForce(velocityChange, ForceMode.VelocityChange);
}
void AddGravity(){
rb.AddForce(-gravityForce*myNormal);
}
void GetMouseLook(){
//
float yRot = Input.GetAxis("Mouse X") * sensitivity;
float xRot = Input.GetAxis("Mouse Y") * sensitivity;
transform.rotation *= Quaternion.Euler (0f, yRot, 0f);
// m_CameraTargetRot *= Quaternion.Euler (-xRot, 0f, 0f);
//
// if(clampVerticalRotation)
// m_CameraTargetRot = ClampRotationAroundXAxis (m_CameraTargetRot);
//
// if(smooth)
// {
// character.localRotation = Quaternion.Slerp (character.localRotation, m_CharacterTargetRot,
// smoothTime * Time.deltaTime);
// camera.localRotation = Quaternion.Slerp (camera.localRotation, m_CameraTargetRot,
// smoothTime * Time.deltaTime);
// }
// else
// {
// character.localRotation = m_CharacterTargetRot;
// camera.localRotation = m_CameraTargetRot;
// }
}
void OnCollisionStay(Collision collision){
foreach (ContactPoint contact in collision.contacts) {
Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2, false);
}
}
}
fileFormatVersion: 2
guid: 5d3bfdd38de30f642bac54756738e1a0
timeCreated: 1454527178
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a3ff58d07cb93414c9d22bb9513c7b08
folderAsset: yes
timeCreated: 1454462755
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 41e4f29e5dee9ec48a2538955ef1de71
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:
using System;
using System.Collections.Generic;
using UnityEditor;
namespace UnityStandardAssets.CrossPlatformInput.Inspector
{
[InitializeOnLoad]
public class CrossPlatformInitialize
{
// Custom compiler defines:
//
// CROSS_PLATFORM_INPUT : denotes that cross platform input package exists, so that other packages can use their CrossPlatformInput functions.
// EDITOR_MOBILE_INPUT : denotes that mobile input should be used in editor, if a mobile build target is selected. (i.e. using Unity Remote app).
// MOBILE_INPUT : denotes that mobile input should be used right now!
static CrossPlatformInitialize()
{
var defines = GetDefinesList(buildTargetGroups[0]);
if (!defines.Contains("CROSS_PLATFORM_INPUT"))
{
SetEnabled("CROSS_PLATFORM_INPUT", true, false);
SetEnabled("MOBILE_INPUT", true, true);
}
}
[MenuItem("Mobile Input/Enable")]
private static void Enable()
{
SetEnabled("MOBILE_INPUT", true, true);
switch (EditorUserBuildSettings.activeBuildTarget)
{
case BuildTarget.Android:
case BuildTarget.iOS:
case BuildTarget.WP8Player:
case BuildTarget.BlackBerry:
case BuildTarget.PSM:
case BuildTarget.Tizen:
case BuildTarget.WSAPlayer:
EditorUtility.DisplayDialog("Mobile Input",
"You have enabled Mobile Input. You'll need to use the Unity Remote app on a connected device to control your game in the Editor.",
"OK");
break;
default:
EditorUtility.DisplayDialog("Mobile Input",
"You have enabled Mobile Input, but you have a non-mobile build target selected in your build settings. The mobile control rigs won't be active or visible on-screen until you switch the build target to a mobile platform.",
"OK");
break;
}
}
[MenuItem("Mobile Input/Enable", true)]
private static bool EnableValidate()
{
var defines = GetDefinesList(mobileBuildTargetGroups[0]);
return !defines.Contains("MOBILE_INPUT");
}
[MenuItem("Mobile Input/Disable")]
private static void Disable()
{
SetEnabled("MOBILE_INPUT", false, true);
switch (EditorUserBuildSettings.activeBuildTarget)
{
case BuildTarget.Android:
case BuildTarget.iOS:
case BuildTarget.WP8Player:
case BuildTarget.BlackBerry:
EditorUtility.DisplayDialog("Mobile Input",
"You have disabled Mobile Input. Mobile control rigs won't be visible, and the Cross Platform Input functions will always return standalone controls.",
"OK");
break;
}
}
[MenuItem("Mobile Input/Disable", true)]
private static bool DisableValidate()
{
var defines = GetDefinesList(mobileBuildTargetGroups[0]);
return defines.Contains("MOBILE_INPUT");
}
private static BuildTargetGroup[] buildTargetGroups = new BuildTargetGroup[]
{
BuildTargetGroup.Standalone,
BuildTargetGroup.WebPlayer,
BuildTargetGroup.Android,
BuildTargetGroup.iOS,
BuildTargetGroup.WP8,
BuildTargetGroup.BlackBerry
};
private static BuildTargetGroup[] mobileBuildTargetGroups = new BuildTargetGroup[]
{
BuildTargetGroup.Android,
BuildTargetGroup.iOS,
BuildTargetGroup.WP8,
BuildTargetGroup.BlackBerry,
BuildTargetGroup.PSM,
BuildTargetGroup.Tizen,
BuildTargetGroup.WSA
};
private static void SetEnabled(string defineName, bool enable, bool mobile)
{
//Debug.Log("setting "+defineName+" to "+enable);
foreach (var group in mobile ? mobileBuildTargetGroups : buildTargetGroups)
{
var defines = GetDefinesList(group);
if (enable)
{
if (defines.Contains(defineName))
{
return;
}
defines.Add(defineName);
}
else
{
if (!defines.Contains(defineName))
{
return;
}
while (defines.Contains(defineName))
{
defines.Remove(defineName);
}
}
string definesString = string.Join(";", defines.ToArray());
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, definesString);
}
}
private static List<string> GetDefinesList(BuildTargetGroup group)
{
return new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(group).Split(';'));
}
}
}
fileFormatVersion: 2
guid: db7667203062c644ea1877077e30ebd6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
fileFormatVersion: 2
guid: 7e2f56503bcab1449aeb96749b5835c9
folderAsset: yes
timeCreated: 1454462792
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 16a2449975f5a424ea32e9998e80ab88
folderAsset: yes
timeCreated: 1454462839
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5f3be10b58dcd8d42a1a11808d6459de
folderAsset: yes
timeCreated: 1454462839
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
<sbspresets formatversion="1.0" count="3" >
<sbspreset pkgurl="pkg://BrickWall_02/BrickWall_02" label="var02" >
<presetinput identifier="$randomseed" uid="837365506" type="4" value="-801489055" />
<presetinput identifier="Hue_Shift" uid="1651098722" type="0" value="0.019" />
<presetinput identifier="Saturation" uid="1651098724" type="0" value="0.521" />
<presetinput identifier="Emboss" uid="1659681353" type="0" value="-0.742" />
<presetinput identifier="Angle" uid="1659681397" type="0" value="0.297" />
<presetinput identifier="$outputsize" uid="1721448784" type="8" value="10,10" />
</sbspreset>
<sbspreset pkgurl="pkg://BrickWall_02/BrickWall_02" label="var01" >
<presetinput identifier="$randomseed" uid="837365506" type="4" value="-801489055" />
<presetinput identifier="Hue_Shift" uid="1651098722" type="0" value="0.019" />
<presetinput identifier="Saturation" uid="1651098724" type="0" value="0.521" />
<presetinput identifier="Bricks_X" uid="1653029189" type="4" value="19" />
<presetinput identifier="Emboss" uid="1659681353" type="0" value="-0.742" />
<presetinput identifier="Angle" uid="1659681397" type="0" value="0.614" />
<presetinput identifier="Age" uid="1659747218" type="0" value="0.733" />
<presetinput identifier="$outputsize" uid="1721448784" type="8" value="10,10" />
</sbspreset>
<sbspreset pkgurl="pkg://BrickWall_02/BrickWall_02" label="var03" >
<presetinput identifier="$randomseed" uid="837365506" type="4" value="-801489055" />
<presetinput identifier="Hue_Shift" uid="1651098722" type="0" value="0.952" />
<presetinput identifier="Saturation" uid="1651098724" type="0" value="0.521" />
<presetinput identifier="Bricks_X" uid="1653029189" type="4" value="26" />
<presetinput identifier="Bricks_Y" uid="1653029219" type="4" value="34" />
<presetinput identifier="Emboss" uid="1659681353" type="0" value="5.84" />
<presetinput identifier="Angle" uid="1659681397" type="0" value="0.764" />
<presetinput identifier="Contrast" uid="1659745394" type="0" value="-0.111" />
<presetinput identifier="Normal" uid="1659745552" type="0" value="0.935" />
<presetinput identifier="Age" uid="1659747218" type="0" value="0.733" />
<presetinput identifier="$outputsize" uid="1721448784" type="8" value="10,10" />
</sbspreset>
</sbspresets>
fileFormatVersion: 2
guid: 37fd0da9ec769e24faa762e4bf190b03
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
<sbspresets formatversion="1.0" count="2" >
<sbspreset pkgurl="pkg://Camouflage_02/Camouflage_02" label="var01" >
<presetinput identifier="$outputsize" uid="2436344417" type="8" value="10,10" />
<presetinput identifier="Normal" uid="2500531625" type="0" value="0.512" />
<presetinput identifier="Depth" uid="2500531627" type="0" value="-0.996" />
<presetinput identifier="Contrast" uid="2500531780" type="0" value="0.018" />
<presetinput identifier="Light_Angle" uid="2500532004" type="0" value="0.108" />
<presetinput identifier="Hue_Shift" uid="2500532007" type="0" value="0.186" />
<presetinput identifier="Luminosity" uid="2500532009" type="0" value="0.498" />
<presetinput identifier="$randomseed" uid="3326458931" type="4" value="1363218278" />
</sbspreset>
<sbspreset pkgurl="pkg://Camouflage_02/Camouflage_02" label="var02" >
<presetinput identifier="$outputsize" uid="2436344417" type="8" value="10,10" />
<presetinput identifier="Normal" uid="2500531625" type="0" value="0.512" />
<presetinput identifier="Depth" uid="2500531627" type="0" value="-0.996" />
<presetinput identifier="Contrast" uid="2500531780" type="0" value="0.018" />
<presetinput identifier="Light_Angle" uid="2500532004" type="0" value="0.669" />
<presetinput identifier="Hue_Shift" uid="2500532007" type="0" value="0.445" />
<presetinput identifier="Luminosity" uid="2500532009" type="0" value="0.498" />
<presetinput identifier="Holes" uid="2501586452" type="0" value="0.154" />
<presetinput identifier="Stains" uid="2501652017" type="0" value="0.896" />
<presetinput identifier="$randomseed" uid="3326458931" type="4" value="20445599" />
</sbspreset>
</sbspresets>
fileFormatVersion: 2
guid: e8b95d7122de113418f94b22fd5ddb32
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
<sbspresets formatversion="1.0" count="3" >
<sbspreset pkgurl="pkg://Cereals/Cereals" label="var01" >
<presetinput identifier="Emboss" uid="2583700377" type="0" value="5.762" />
<presetinput identifier="Light_Angle" uid="2583700389" type="0" value="0.097" />
<presetinput identifier="Contrast" uid="2583768482" type="0" value="0.152" />
<presetinput identifier="Saturation" uid="2592431540" type="0" value="0.543" />
<presetinput identifier="Luminosity" uid="2592431543" type="0" value="0.423" />
<presetinput identifier="$outputsize" uid="2658640000" type="8" value="10,10" />
<presetinput identifier="$randomseed" uid="3372594898" type="4" value="-968057035" />
</sbspreset>
<sbspreset pkgurl="pkg://Cereals/Cereals" label="var02" >
<presetinput identifier="Emboss" uid="2583700377" type="0" value="5.762" />
<presetinput identifier="Light_Angle" uid="2583700389" type="0" value="0.122" />
<presetinput identifier="Contrast" uid="2583768482" type="0" value="0.152" />
<presetinput identifier="Depth" uid="2584223578" type="0" value="0.412" />
<presetinput identifier="Saturation" uid="2592431540" type="0" value="0.543" />
<presetinput identifier="Luminosity" uid="2592431543" type="0" value="0.423" />
<presetinput identifier="Milk_Level" uid="2612442444" type="0" value="0.196" />
<presetinput identifier="Colour_Variation" uid="2612873744" type="0" value="0.33" />
<presetinput identifier="$outputsize" uid="2658640000" type="8" value="10,10" />
<presetinput identifier="$randomseed" uid="3372594898" type="4" value="-968057035" />
</sbspreset>
<sbspreset pkgurl="pkg://Cereals/Cereals" label="var03" >
<presetinput identifier="Emboss" uid="2583700377" type="0" value="5.762" />
<presetinput identifier="Light_Angle" uid="2583700389" type="0" value="0.122" />
<presetinput identifier="Contrast" uid="2583768482" type="0" value="0.152" />
<presetinput identifier="Depth" uid="2584223578" type="0" value="0.412" />
<presetinput identifier="Saturation" uid="2592431540" type="0" value="0.543" />
<presetinput identifier="Luminosity" uid="2592431543" type="0" value="0.423" />
<presetinput identifier="Milk_Level" uid="2612442444" type="0" value="0.407" />
<presetinput identifier="Colour_Variation" uid="2612873744" type="0" value="0.412" />
<presetinput identifier="Cereal_Type" uid="2612874415" type="4" value="1" />
<presetinput identifier="$outputsize" uid="2658640000" type="8" value="10,10" />
<presetinput identifier="$randomseed" uid="3372594898" type="4" value="-1758347690" />
</sbspreset>
</sbspresets>
fileFormatVersion: 2
guid: 682b238ecc216234d856f3638924165f
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
<sbspresets formatversion="1.0" count="3" >
<sbspreset pkgurl="pkg://Desert_Sand_01/Desert_Sand_01" label="var01" >
<presetinput identifier="Waves_Width" uid="1102048223" type="0" value="0.565" />
<presetinput identifier="Waves_Warp" uid="1103311776" type="0" value="0.94" />
<presetinput identifier="Waves_Lenght" uid="1103324536" type="0" value="0.737" />
<presetinput identifier="Zoom" uid="1103327370" type="0" value="0.838" />
<presetinput identifier="$outputsize" uid="1143389743" type="8" value="9,9" />
</sbspreset>
<sbspreset pkgurl="pkg://Desert_Sand_01/Desert_Sand_01" label="var02" >
<presetinput identifier="Sand_Color" uid="1056719830" type="2" value="0.843,0.831,0.776" />
<presetinput identifier="Waves_Width" uid="1102048223" type="0" value="0.812" />
<presetinput identifier="Waves_Warp" uid="1103311776" type="0" value="0.175" />
<presetinput identifier="Waves_Lenght" uid="1103324536" type="0" value="0" />
<presetinput identifier="Zoom" uid="1103327370" type="0" value="0.951" />
<presetinput identifier="$outputsize" uid="1143389743" type="8" value="9,9" />
</sbspreset>
<sbspreset pkgurl="pkg://Desert_Sand_01/Desert_Sand_01" label="var03" >
<presetinput identifier="Sand_Color" uid="1056719830" type="2" value="0.843,0.808,0.729" />
<presetinput identifier="Flow" uid="1074373339" type="0" value="1318.36" />
<presetinput identifier="Normal" uid="1078997615" type="0" value="1" />
<presetinput identifier="Emboss" uid="1079065910" type="0" value="10" />
<presetinput identifier="Waves_Width" uid="1102048223" type="0" value="0.856" />
<presetinput identifier="Waves_Warp" uid="1103311776" type="0" value="1" />
<presetinput identifier="Waves_Lenght" uid="1103324536" type="0" value="0.049" />
<presetinput identifier="Zoom" uid="1103327370" type="0" value="0.028" />
<presetinput identifier="$outputsize" uid="1143389743" type="8" value="9,9" />
</sbspreset>
</sbspresets>
fileFormatVersion: 2
guid: e9465ce23ed227b4a94175c541346aa8
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
<sbspresets formatversion="1.0" count="4" >
<sbspreset pkgurl="pkg://Electric_Liquid/Electric_Liquid" label="var01" >
<presetinput identifier="$outputsize" uid="694699089" type="8" value="9,9" />
<presetinput identifier="Flow" uid="748611366" type="0" value="351.562" />
<presetinput identifier="Glow_Intensity" uid="754481806" type="0" value="0.35" />
<presetinput identifier="Glow_Size" uid="754481913" type="0" value="3.149" />
</sbspreset>
<sbspreset pkgurl="pkg://Electric_Liquid/Electric_Liquid" label="var02" >
<presetinput identifier="$outputsize" uid="694699089" type="8" value="9,9" />
<presetinput identifier="Flow" uid="748611366" type="0" value="351.562" />
<presetinput identifier="Glow_Intensity" uid="754481806" type="0" value="0.35" />
<presetinput identifier="Glow_Size" uid="754481913" type="0" value="0" />
<presetinput identifier="Liquid_Color" uid="1404575099" type="2" value="0.318,0.741,0.439" />
<presetinput identifier="$randomseed" uid="2115654147" type="4" value="-1708597500" />
</sbspreset>
<sbspreset pkgurl="pkg://Electric_Liquid/Electric_Liquid" label="var03" >
<presetinput identifier="$outputsize" uid="694699089" type="8" value="9,9" />
<presetinput identifier="Flow" uid="748611366" type="0" value="351.562" />
<presetinput identifier="Glow_Intensity" uid="754481806" type="0" value="0.83" />
<presetinput identifier="Glow_Size" uid="754481913" type="0" value="0" />
<presetinput identifier="Liquid_Color" uid="1404575099" type="2" value="0.471,0.741,0.741" />
<presetinput identifier="$randomseed" uid="2115654147" type="4" value="-1466697349" />
</sbspreset>
<sbspreset pkgurl="pkg://Electric_Liquid/Electric_Liquid" label="var04" >
<presetinput identifier="$outputsize" uid="694699089" type="8" value="9,9" />
<presetinput identifier="Flow" uid="748611366" type="0" value="351.562" />
<presetinput identifier="Glow_Intensity" uid="754481806" type="0" value="0.411" />
<presetinput identifier="Glow_Size" uid="754481913" type="0" value="5" />
<presetinput identifier="Liquid_Color" uid="1404575099" type="2" value="0.373,0.125,0.741" />
<presetinput identifier="$randomseed" uid="2115654147" type="4" value="700204438" />
</sbspreset>
</sbspresets>
fileFormatVersion: 2
guid: 52c66ce41a350394d9b6126b5ab0c06c
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment