I’ve got a scene there there are 3 layers of 30 objects, each with their own box colliders. The way the “game” works atm is when the player presses A S or D if the sprite is next to a object, the “digs” through and removes it. The issue comes in when the sprite is on the second layer and trying to dig through the sides of an object. The sprite seems to sink into one of the objects below and destroys them instead
I’ll link a video to show it in action, maybe it will be easier to see it happening: Desktop 2018 04 30 20 52 54 04 - YouTube
If anyone can suggest possible solutions, that would be great
EDIT:
Player movement
void Update () {
float axisX = Input.GetAxis ("Horizontal");
float axisY = Input.GetAxis ("Vertical");
transform.Translate (new Vector3 (axisX, axisY) * Time.deltaTime * speed);
//Speed is set to 10
}
Object removal
void OnCollisionStay2D(Collision2D collStay)
{
if (isTriggered == false && Input.GetKey ("s")){
countDown -= Time.deltaTime;
print (countDown);
if (countDown <= 0) {
dirtCount = dirtCount + 1;
print (dirtCount);
Destroy (collStay.gameObject);
countDown = 2.0f;
}
}
if (enteredBlockSide == true && Input.GetKey ("d")){
countDown -= Time.deltaTime;
print (countDown);
if (countDown <= 0) {
dirtCount = dirtCount + 1;
print (dirtCount);
Destroy (collStay.gameObject);
countDown = 2.0f;
}
}
if (enteredBlockSide == true && Input.GetKey ("a")){
countDown -= Time.deltaTime;
print (countDown);
if (countDown <= 0) {
dirtCount = dirtCount + 1;
print (dirtCount);
Destroy (collStay.gameObject);
countDown = 2.0f;
}
}
}
isTriggered is there to stop removal of 2 objects at once.
enteredBlockSide is a Linecast which I was hoping would solve my issue (it didn’t).