I’m trying to recreate the sonic boss fight from the game “I wanna be the boshy” just for fun and currently I’m at the stage where I’m programming super sonic and trying to program this attack: I Wanna Be The Boshy -- Sonic [IWBTB] - YouTube
I’m using this function that is run in the Update loop for the attack:
public void SuperFly(float speed, float maxSpeed)
{
float xa = speed;
float ya = speed;
flyV = rig.velocity;
xv = Mathf.Clamp(xv, -maxSpeed, maxSpeed);
yv = Mathf.Clamp(yv, -maxSpeed, maxSpeed);
flyV.x = xv;
flyV.y = yv;
rig.velocity = flyV;
Vector2 v = rig.velocity;
float angle = Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
transform.localScale = new Vector3(1, 1, 1);
if(!runningState) //Start Of State
{
stateTimer = 30f;
anim.SetTrigger("SuperFly");
transform.position = deathPoint.transform.position;
runningState = true;
}
if (transform.position.x > player.transform.position.x)
{
xv -= xa;
}
else
{
xv += xa;
}
if (transform.position.y > player.transform.position.y)
{
yv -= ya;
}
else
{
yv += ya;
}
}
It seems to be very similar to the movement in the game but there is just something about it that is off and I can’t tell what. It seems sonic’s movements in the actual game is a lot more quick and sharp then mine are but I’m not sure how I can edit my code to make that happen. This is what the movement looks like within my game:
If you look at the video and my gif then you should be able to see a difference with the movement but as I said, I’m just unsure what to change. I’d love some help