- Home /
Need help with moving an empty game object from one side of my player to the other
So I recently followed a melee combat tutorial and in that tutorial they used an empty game object as a sort of hitbox for the melee weapon. When I tried it it worked fine but it would stay at the right side of my player even when my player was facing left. I flip my character using the flipX and flipY functions of the sprite renderer. Is there anyway I can move the empty game object to the other side of my player when he flips that way? https://youtu.be/1QfxdUpVh5I This is the tutorial I followed. Also keep in mind that I am a total rookie at coding and using unity since I started using it very recently.
Answer by brian1gramm1 · Jun 08, 2021 at 09:22 PM
My understanding of sprite flipping is that it is basically negating the x axis (-x). So multiplying your hitbox transform x by -1 would switch sides. The better way might be to have two hitboxs, one on the left and right, and turn them on and off respectively.
Thanks! Having 2 hitboxes like you suggested worked flawlessly
Your answer
![](https://koobas.hobune.stream/wayback/20220613034751im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object moves to 0,0,0? (Just want to know why it works) 1 Answer
Game Object not moving in Canvas 0 Answers
Vector3.Lerp not working? 5 Answers
gameObject moves twice? 0 Answers
Drag game object with finger 1 Answer