I’m having some issues with my Mario clone game.
First I don’t like the way my ground detecting works right now because I feel like it slows the character down when he lands, maybe its me, but here is an example of a collision on the floor.
if (other.tag == "Floor")
{
transform.position.y = 3.028204;
grounded = true;
if (faceRight)
animation.Play("IdleRight");
else
animation.Play("IdleLeft");
}
Notice I transform the position to a specific y value a feel like for a split frame while its adjusting the y value the player is frozen, maybe I’m just imagining things. If I exclude this part of the script they stop, but many times it is later then I would like and Mario ends up through part of the floor or object he landed on.
Another issue I am running into is with floating blocks I have 3 collision box’s for each side of them and when I jump really close to the the side of one and hold into the box I get a lot of random results, either he hits it and bounces down (which is fine), gets stuck on the corner for a second and either pushed out or on top, or he teleports to the top (this is due to a similar collision as the floor that sets the y value.
I tried adjusting the collision box sizes, but nothing seems to work, maybe I should move the side boxes out more?
The second issue I have is with my enemies. Right now I have a hitbox on their head to my character to land on. This works fine, what I noticed was when I walked into them and died they still played their death animation. Turns out it was detecting if the hitbox from my character touched ANY of the collision boxs the enemy had. I only want it to do the head, since the script was attached to the actual enemy entity it does this, if I apply it to the head it doesn’t:
if (other.tag == "MarioFeet")
{
gameObject.animation.Play("GoombaDeath");
GoombaAIScript.move = 0;
MarioMove.jumpSpeed = 0.3;
}
Since the script is on the actual object it plays the animation which triggers the destroy function in the events. The questions is how do I get the head collision box to detect the game object its attached to play the animation? Also is it possible to do this in a script not attached to the head? I hate having a script on so many different pieces of a character/enemy.
The third thing is the camera I made a script to follow Mario when he hits a collision box and is hold right the camera follows otherwise it stops. Problem is I am finding a lot of times where I clip through the collision box. I initially found if I held left first then right I would walk through it, I fixed this by making sure as long as left was being held to do it. Right now I can get through the collision if I fake it out by pressing left quickly then right. Any solutions?
Last questions not specific to collision, but is it normal to have a TON of tags? I have to have at least 50+ right now.
Anyway thank you for the help in advanced.