CT APE

【Introduction】

CT ape has to fight with bugs, try to mess up enemy and win the game at the same time!



【Game link】



【Github】



【Note】

Due to the experience of Eat Honey, I can’t figure out the collision of puzzle, and it cause a bug keeps puzzle stucking.

Original method: Player controls puzzle, and puzzle itself check the object of collision.
Bug: the position of last frame is vary from every pc, position of the puzzle may set to the one after collide and puzzle set to can’t move at the same time.

boxbox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "box")
{
transform.position = lastPos;
canMove = false;
}
if (collision.tag == "Player")
{
player = collision.GetComponent<Player>();
player.canMove = false;
player.LastPos();
}
}

The teammate helped me to find out that check collision by raycast.

  1. Check if it’s the same puzzle from player raycast and player interactive
  2. Set all puzzles to static when player release interact key
playerplayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void raycastBox()
{
RaycastHit2D o = Physics2D.Linecast(transform.position, transform.position + faceTo, test);
if (o)
{
if (Input.GetKey(interact))
{
o.collider.gameObject.GetComponent<Box>().followPlayer(boxSpeedX, boxSpeedY);
o.collider.GetComponent<Box>().checkName(o.collider.gameObject.name);
canDragOther = false;
}
}
if (Input.GetKeyUp(interact)) {
canDragOther = true;
for (int i = 0; i < GameObject.FindGameObjectsWithTag("box").Length; i++)
{
FindObjectsOfType<Box>()[i].GetComponent<Box>().setStatic();
}
}
}
prev:321 Stop! next:Animal Escape