First part

This commit is contained in:
Marc-Antoine Dumont 2015-10-29 20:42:26 -04:00
parent 1ec4de6231
commit 4a2a0fd111
4 changed files with 52 additions and 2 deletions

Binary file not shown.

View File

@ -4,13 +4,15 @@ public class Character{
private int mass;
private int mouvementSpeed { get; set; }
private int forceJump { get; set; }
private bool touchingTheFloor;
public Character(int m, int mvtSpeed, int fJump)
public Character(int m, int mvtSpeed, int fJump, bool touchFloor)
{
this.mass = m;
this.mouvementSpeed = mvtSpeed;
this.forceJump = fJump;
this.touchingTheFloor = touchFloor;
}
@ -23,5 +25,13 @@ public class Character{
this.mass = m;
}
public void setTouchingTheFloor(bool touchFloor){
this.touchingTheFloor = touchFloor;
}
public bool isTouchingTheFloor()
{
return touchingTheFloor;
}
}

View File

@ -4,9 +4,49 @@ using System.Collections;
public class Gravity : MonoBehaviour {
public Character player;
void Start()
{
player = new Character(1, 10, 10, false);
}
// Update is called once per frame
void Update () {
int test = player.getMass();
if (!player.isTouchingTheFloor())
{
this.gameObject.transform.Translate(0,-0.1f,0);
}
if (Input.GetKey("p"))
{
player.setTouchingTheFloor(false);
}
}
void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.tag == "Floor")
{
player.setTouchingTheFloor(true);
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "Floor")
{
player.setTouchingTheFloor(false);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Floor")
{
player.setTouchingTheFloor(true);
}
}
}

Binary file not shown.