ya plus de (autant) de troue

This commit is contained in:
happy44300
2018-10-06 22:44:04 +02:00
parent c0261ff0cd
commit 0a01c038f0
70 changed files with 9342 additions and 46 deletions
+85 -46
View File
@@ -3,7 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public class PlayerController : MonoBehaviour
{
Rigidbody2D rb2;
[SerializeField]
float sensiX = 1;
@@ -19,55 +20,83 @@ public class PlayerController : MonoBehaviour {
private bool IsGrounded = true;
RaycastHit2D hit;
SpriteRenderer rend;
bool flip_flop = false;
private Vector2 _lastpos = Vector2.zero;
private Vector2 _lastpos = Vector2.zero;
public string Horizontal = "Horizontal";
public string Vertical = "Vertical";
<<<<<<< HEAD
void Start() {
=======
// Use this for initialization
void Start () {
void Start ()
{
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
rb2 = gameObject.GetComponent<Rigidbody2D>();
layerMask = ~layerMask;
rend = gameObject.GetComponent<SpriteRenderer>();
_lastpos = transform.position;
}
<<<<<<< HEAD
void Update() {
=======
// Update is called once per frame
void Update () {
void Update ()
{
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
DectectInput();
}
<<<<<<< HEAD
#region
void OnCollisionStay2D(Collision2D other)
{
if (other.transform != null && hit.transform != null)
=======
void OnCollisionStay2D(Collision2D other)
{
if (other.transform != null && hit.transform !=null)
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
{
if (other.transform.name == hit.transform.name)
{
IsGrounded = true;
<<<<<<< HEAD
}
}
}
=======
}
}
}
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
void DectectInput()
{
float horizontal = Input.GetAxisRaw("Horizontal")*sensiX;
float rawtical = Input.GetAxisRaw("Vertical")*sensiY;
float horizontal = Input.GetAxisRaw(Horizontal) * sensiX;
float rawtical = Input.GetAxisRaw(Vertical) * sensiY;
switch (Mathf.RoundToInt(Input.GetAxisRaw("Vertical")))
switch (Mathf.RoundToInt(Input.GetAxisRaw(Vertical)))
{
case 1:
vertical = 1 * sensiY;
break;
case -1:
break;
case 0:
vertical = 0;
break;
default:
@@ -75,38 +104,33 @@ public class PlayerController : MonoBehaviour {
break;
}
//if( transform.position.y < _lastpos.y)
//{
// rb2.gravityScale = echo_act_3;
//}
//else
//{
// rb2.gravityScale = 1;
//}
//_lastpos = transform.position;
hit = Physics2D.Raycast(transform.position, Vector2.down, DownDetector, layerMask);
if(hit.collider == null)
<<<<<<< HEAD
if (hit.collider == null)
{
IsGrounded = false;
IsGrounded = false;
}
if (IsGrounded == false)
{
=======
if(hit.collider == null)
{
IsGrounded = false;
}
if (IsGrounded == false)
{
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
vertical = 0;
}
Move(horizontal, vertical);
@@ -118,11 +142,11 @@ public class PlayerController : MonoBehaviour {
{
rb2.gravityScale = 1;
}
}
private void Move(float horizontal, float vertical)
{
if (horizontal == 0)
if (horizontal == 0)
{
rb2.velocity = new Vector2(0, rb2.velocity.y);
}
@@ -131,25 +155,40 @@ public class PlayerController : MonoBehaviour {
if (horizontal > 0)
{
rend.flipX = true;
}else if (horizontal < 0)
<<<<<<< HEAD
} else if (horizontal < 0)
=======
}
else if (horizontal < 0)
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
{
rend.flipX = false;
}
if(vertical > 0)
if (vertical > 0)
{
rend.flipY = true;
rend.flipY = true;
}
else
{
rend.flipY = false;
}
rb2.AddForce(new Vector2(horizontal, vertical)*Time.deltaTime, ForceMode2D.Impulse);
<<<<<<< HEAD
rb2.AddForce(new Vector2(horizontal, vertical) * Time.deltaTime, ForceMode2D.Impulse);
}
#endregion
public void Die()
{
Debug.Log("Belle journée pour mourir");
}
=======
rb2.AddForce(new Vector2(horizontal, vertical)*Time.deltaTime, ForceMode2D.Impulse);
}
>>>>>>> 26f285ae27df3e2756e31ec432f0687368a8cfcb
}