Merge branch 'master' into respawn

This commit is contained in:
Jan Groß
2018-09-01 12:49:46 +02:00
committed by GitHub
5 changed files with 107 additions and 20 deletions

8
Assets/Models.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 681795e0efcef2f49b1daca1f3fa92ab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 14b85f16408b89747a9bff89f8fe49b6 guid: 9742d4800b8a66b4d9ec800f36840aff
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@@ -265,9 +265,13 @@ MonoBehaviour:
lockMouse: 1 lockMouse: 1
speed: 0.5 speed: 0.5
theLurch: {fileID: 4675101163920296} theLurch: {fileID: 4675101163920296}
lurchMaterial: {fileID: 0}
maxJumpForce: 10 maxJumpForce: 10
forceIncreaseSpeed: 0.5 forceIncreaseSpeed: 0.5
normalColor: {r: 0.14509805, g: 0.4784314, b: 1, a: 0} normalColor: {r: 0.14509805, g: 0.4784314, b: 1, a: 0}
fullyChargedColor: {r: 1, g: 0.6223973, b: 0, a: 0} fullyChargedColor: {r: 0.95649004, g: 0, b: 1, a: 0}
normalSize: {x: 0, y: 0, z: 0}
chargedSizeModifier: 0.5
canStick: 1 canStick: 1
cooldown: 0
canGlide: 1
glideForce: 3

View File

@@ -477,6 +477,16 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 5 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 114123996009525022, guid: 8bcf2afca6664234f83b5ee8381b1975,
type: 2}
propertyPath: canGlide
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114123996009525022, guid: 8bcf2afca6664234f83b5ee8381b1975,
type: 2}
propertyPath: glideForce
value: 3
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8bcf2afca6664234f83b5ee8381b1975, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 8bcf2afca6664234f83b5ee8381b1975, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0

View File

@@ -21,35 +21,55 @@ public class LurchMovement : MonoBehaviour {
[Header("Lurch")] [Header("Lurch")]
public Transform theLurch; public Transform theLurch;
private Rigidbody lurchBody; private Rigidbody lurchBody;
public Material lurchMaterial;
[Header("Jump Charge")]
public float maxJumpForce; public float maxJumpForce;
private float currentJumpForce; private float currentJumpForce;
public float forceIncreaseSpeed; public float forceIncreaseSpeed;
public Color normalColor; public Color normalColor;
public Color fullyChargedColor; public Color fullyChargedColor;
private Color lerpedColor;
public Vector3 normalSize;
[Range(0.1f, 1.0f)]
public float chargedSizeModifier;
private Vector3 chargedSize;
private Vector3 currentSize;
static float t = 0.0f;
[Header("Jump n Stick")] [Header("Jump n Stick")]
public bool canStick; public bool canStick;
[SerializeField]
private float cooldown; private float cooldown;
[Header("Gliding")]
public bool canGlide;
private Vector3 glideSize;
[Range(1.0f, 10.0f)]
public float glideForce;
private void Start() private void Start()
{ {
lurchBody = theLurch.GetComponent<Rigidbody>(); lurchBody = theLurch.GetComponent<Rigidbody>();
normalSize = theLurch.transform.localScale;
chargedSize = theLurch.transform.localScale * chargedSizeModifier;
glideSize = new Vector3(normalSize.x, normalSize.y * 0.5f, normalSize.z);
} }
void Update() void Update()
{ {
theLurch.rotation = Quaternion.Euler(0, transform.eulerAngles.y, 0); theLurch.rotation = Quaternion.Euler(0, transform.eulerAngles.y, 0);
theLurch.GetComponent<Renderer>().material.color = lerpedColor;
theLurch.transform.localScale = currentSize;
MouseControl(); MouseControl();
JumpControl(); JumpControl();
SmoothFollow(); SmoothFollow();
Gliding();
Debug.DrawRay(theLurch.position, Vector3.down * 0.45f, Color.blue);
} }
void MouseControl() void MouseControl()
@@ -94,15 +114,33 @@ public class LurchMovement : MonoBehaviour {
if (Input.GetButton("Fire1") && currentJumpForce < maxJumpForce) if (Input.GetButton("Fire1") && currentJumpForce < maxJumpForce)
{ {
currentJumpForce += forceIncreaseSpeed; currentJumpForce += forceIncreaseSpeed;
lerpedColor = Color.Lerp(normalColor, fullyChargedColor, t);
if (t < 1.0f)
{
t += 2 * Time.deltaTime;
}
currentSize = Vector3.Lerp(currentSize, chargedSize, Time.deltaTime * 1.5f);
}
else if(!Input.GetButton("Fire1"))
{
lerpedColor = normalColor;
t = 0.0f;
currentSize = normalSize;
} }
if (cooldown > 0.0f) if (cooldown > 0.0f)
{
cooldown -= Time.deltaTime; cooldown -= Time.deltaTime;
currentJumpForce = 0.0f;
}
if (Input.GetButtonUp("Fire1")) { if (Input.GetButtonUp("Fire1")) {
cooldown += 0.5f; cooldown = 0.5f;
lurchBody.isKinematic = false; lurchBody.isKinematic = false;
Debug.Log("Ich springe");
lurchBody.AddForce(theLurch.forward * currentJumpForce, ForceMode.Impulse); lurchBody.AddForce(theLurch.forward * currentJumpForce, ForceMode.Impulse);
lurchBody.AddForce(theLurch.up * currentJumpForce, ForceMode.Impulse); lurchBody.AddForce(theLurch.up * currentJumpForce, ForceMode.Impulse);
} }
@@ -110,31 +148,58 @@ public class LurchMovement : MonoBehaviour {
{ {
lurchBody.isKinematic = true; lurchBody.isKinematic = true;
} }
else if (!LurchOnGround() && Time.time > cooldown && !AmSticking())
if (!LurchOnGround())
{ {
currentJumpForce = 0.0f; currentJumpForce = 0.0f;
lurchBody.isKinematic = false;
} }
}
void Gliding()
{
if (canGlide && !lurchBody.isKinematic && Input.GetButton("Fire1") &&!LurchOnGround())
{
Debug.Log("Ich kann jetzt gleiten");
theLurch.transform.localScale = glideSize;
lurchBody.AddForce(theLurch.forward * glideForce);
lurchBody.AddForce(theLurch.up * 0.08f, ForceMode.Impulse);
}
if (!Input.GetButton("Fire1"))
{
theLurch.transform.localScale = currentSize;
}
} }
public bool LurchOnGround() public bool LurchOnGround()
{ {
RaycastHit hit; RaycastHit hit;
if (Physics.Raycast(theLurch.position, Vector3.down, out hit, 0.4f)) if (Physics.Raycast(theLurch.position, Vector3.down, out hit, 0.36f) && cooldown <= 0.0f)
{ {
return true; return true;
} }
if (canStick) if (AmSticking())
{ {
return true;
}
Debug.DrawRay(theLurch.position, Vector3.forward* 1.6f); return false;
}
if (Physics.Raycast(theLurch.position, Vector3.forward, out hit, 1.6f)) bool AmSticking()
{ {
return true; RaycastHit hit;
} if (Physics.Raycast(theLurch.position, theLurch.forward, out hit, 1.4f))
{
return true;
}
if (lurchBody.isKinematic)
{
return true;
} }
return false; return false;