I’m working on a game, had to slowly teach myself whatever ins and outs of the engine I could. Now I’ve run into an issue and I have no clue how to fix it. And I haven’t seen anyone have a similar issue. Basically, everytime my character attacks, they fly across the screen. I’ve narrowed it down to collider and gameObject moving together. So, my question is, how can I move a collider to a spot I want it without moving the gameObject? I’m working with CircleCollider2D.
void MeleeAttack (int dmg, int shlddmg, float kbx, float kby, float spkbx, float spkby, float hbrad, float hbx, float hby) //Sets up attack properties
{
HitCollider = gameObject.AddComponent<CircleCollider2D>();
HitCollider.isTrigger = true;
AtkDmg = dmg;
ShldDmg = shlddmg;
AtkKBy = kby;
SpecialKBy = spkby;
HitCollider.radius = hbrad;
if (FaceDirection == "right") {
AtkKBx = kbx;
SpecialKBx = spkbx;
HitCollider.transform.Translate (hbx, hby, 0);
}
if (FaceDirection == "left") {
AtkKBx = -kbx;
SpecialKBx = -spkbx;
HitCollider.transform.Translate (-hbx, hby, 0);
}
}