Skip to content
Snippets Groups Projects
Commit c9bb8362 authored by kgingras's avatar kgingras
Browse files

camera and movement fixed. need gravity fix

parent b724bec4
No related branches found
No related tags found
No related merge requests found
Showing
with 144 additions and 400 deletions
fileFormatVersion: 2
guid: e8ef930c672fcce4a88723bcce7a2591
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: //RootNode
100002: default
400000: //RootNode
400002: default
2300000: default
3300000: default
4300000: default
9500000: //RootNode
materials:
importMaterials: 0
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: .200000003
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: 1
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: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: ecfb6127c152e4c47971eb3468c22e52
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: default
100002: //RootNode
400000: default
400002: //RootNode
2300000: default
3300000: default
4300000: default
9500000: //RootNode
materials:
importMaterials: 0
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: .200000003
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: 1
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: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e33b26c6a6d37ef4f90adaf0fd9c400b
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: default
100002: //RootNode
400000: default
400002: //RootNode
2300000: default
3300000: default
4300000: default
9500000: //RootNode
materials:
importMaterials: 0
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: .200000003
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: 1
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: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0e9a3174d6fdec34688582dfd4ab5659
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: default
100002: //RootNode
400000: default
400002: //RootNode
2300000: default
3300000: default
4300000: default
9500000: //RootNode
materials:
importMaterials: 0
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: .129999995
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: 1
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: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 4b2c64d20843bab46aaf16bcfc37649a
ModelImporter:
serializedVersion: 18
fileIDToRecycleName:
100000: default
100002: //RootNode
400000: default
400002: //RootNode
2300000: default
3300000: default
4300000: default
9500000: //RootNode
materials:
importMaterials: 0
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: .0799999982
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: 1
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: 0
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -17,6 +17,9 @@ public class MouseOrbitC : MonoBehaviour {
private float x = 0.0f;
private float y = 0.0f;
private Vector3 forward = Vector3.zero;
private Vector3 right = Vector3.zero;
private Vector3 up = Vector3.zero;
CapsuleController CCscript;
......@@ -34,22 +37,27 @@ public class MouseOrbitC : MonoBehaviour {
// Update is called once per frame
void LateUpdate () {
if (target) {
//get the zero angle from vector forward
forward = CCscript.myForward;
Debug.Log (forward);
//float yRot = Input.GetAxis("Mouse X") * sensitivity
//get the zero angle from right vector
right = CCscript.myRight;
x += Input.GetAxis("Mouse X") * sensitivity;
y -= Input.GetAxis("Mouse Y") * sensitivity;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation = Quaternion.Euler(y, x, 0);
Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
//rotate the camera about the players right vector
Quaternion rotX = Quaternion.AngleAxis(y, right);
//Quaternions angles add together through Multiplication
transform.rotation = rotX*target.transform.rotation;
// forward = CCscript.myForward;
// up = CCscript.myNormal;
// float yRot = Input.GetAxis("Mouse X") * sensitivity
// Quaternion rotation = rotY * rotX;
// Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position;
// Vector3 position = -forward * distance + target.position;
// transform.position = position;
}
}
......
......@@ -68,6 +68,7 @@ namespace UnityStandardAssets.Characters.ThirdPerson
//
if (move.magnitude > 1f) move.Normalize();
move = transform.InverseTransformDirection(move);
CheckGroundStatus();
move = Vector3.ProjectOnPlane(move, newNormal);
// m_TurnAmount = Mathf.Atan2(move.x, move.z);
......
fileFormatVersion: 2
guid: 4a49a0c7a2c2b5c4c8c41ac9b1789c32
guid: 2a01b677ccb3d7a4ab321f4632002f66
folderAsset: yes
timeCreated: 1454468344
timeCreated: 1454539362
licenseType: Free
DefaultImporter:
userData:
......
using UnityEngine;
using System.Collections;
public class ThirdPersonAnimator : MonoBehaviour {
[SerializeField] float m_MovingTurnSpeed = 360;
[SerializeField] float m_StationaryTurnSpeed = 180;
[SerializeField] float m_JumpPower = 12f;
[Range(1f, 4f)][SerializeField] float m_GravityMultiplier = 2f;
[SerializeField] float m_RunCycleLegOffset = 0.2f; //specific to the character in sample assets, will need to be modified to work with others
[SerializeField] float m_MoveSpeedMultiplier = 1f;
[SerializeField] float m_AnimSpeedMultiplier = 1f;
[SerializeField] float m_GroundCheckDistance = 0.1f;
Rigidbody m_Rigidbody;
Animator m_Animator;
bool m_IsGrounded= true;
float m_OrigGroundCheckDistance;
const float k_Half = 0.5f;
float m_TurnAmount;
float m_ForwardAmount;
Vector3 m_GroundNormal;
float m_CapsuleHeight;
Vector3 m_CapsuleCenter;
CapsuleCollider m_Capsule;
bool m_Crouching;
CapsuleController CCscript;
// Use this for initialization
void Start () {
m_Animator = GetComponent<Animator>();
CCscript = GameObject.Find("Capsule").GetComponent<CapsuleController>();
//m_Rigidbody = GetComponent<Rigidbody>();
//m_Capsule = GetComponent<CapsuleCollider>();
//m_CapsuleHeight = m_Capsule.height;
//m_CapsuleCenter = m_Capsule.center;
//m_Rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
//m_OrigGroundCheckDistance = m_GroundCheckDistance;
}
// Update is called once per frame
void Update () {
}
public void Move(Vector3 move, bool crouch, bool jump, float yRot){
if (move.magnitude / 20 > 1f) move.Normalize();
move = transform.InverseTransformDirection(move);
// Debug.Log (move.z);
// CheckGroundStatus();
// move = Vector3.ProjectOnPlane(move, CCscript.myNormal);
m_TurnAmount = Mathf.Atan2(yRot, move.z);
m_ForwardAmount = move.z;
// if(move.z >0){
// m_Animator.Play("jog_aim");
// }else{
// m_Animator.Play("stand_idle");
// }
UpdateAnimator(move);
}
void UpdateAnimator(Vector3 move)
{
// update the animator parameters
m_Animator.SetFloat("Forward", m_ForwardAmount, 0.1f, Time.deltaTime);
m_Animator.SetFloat("Turn", m_TurnAmount, 0.1f, Time.deltaTime);
m_Animator.SetBool("Crouch", m_Crouching);
m_Animator.SetBool("OnGround", m_IsGrounded);
if (!m_IsGrounded)
{
m_Animator.SetFloat("Jump", m_Rigidbody.velocity.y);
}
// calculate which leg is behind, so as to leave that leg trailing in the jump animation
// (This code is reliant on the specific run cycle offset in our animations,
// and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5)
float runCycle =
Mathf.Repeat(
m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime + m_RunCycleLegOffset, 1);
float jumpLeg = (runCycle < k_Half ? 1 : -1) * m_ForwardAmount;
if (m_IsGrounded)
{
m_Animator.SetFloat("JumpLeg", jumpLeg);
}
// the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector,
// which affects the movement speed because of the root motion.
if (m_IsGrounded && move.z > 0)
{
m_Animator.speed = m_AnimSpeedMultiplier;
}
else if (m_IsGrounded && move.z < 0)
{
m_Animator.speed = m_AnimSpeedMultiplier;
}
else
{
// don't use that while airborne
m_Animator.speed = 1;
}
}
}
fileFormatVersion: 2
guid: dc7979304313810459266cf94de4d1bb
timeCreated: 1454542987
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
......@@ -4,7 +4,7 @@ using System.Collections;
public class gravity : MonoBehaviour {
public GameObject CoG;
public float gravityStrength = -9.8f;
public float gravityStrength = 9.8f;
Rigidbody rb;
// Use this for initialization
......@@ -14,8 +14,7 @@ public class gravity : MonoBehaviour {
// Update is called once per frame
void Update () {
Vector3 gravDirection = transform.position - CoG.transform.position;
rb.AddForce(gravDirection * gravityStrength);
rb.AddRelativeForce(-gravityStrength*Vector3.up);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment