C
C#8mo ago
MrZone

❔ Flip GameObject with Parent

Yo im using an GameObject for my Mele range, and i wanted to do it flip with my parent but my code is not working, i miss some transform. but idk how to use it on my script idk i tried this code (i use it on my spriterenderer, i changed the "spriterenderer." but i let it for the example)
void Flip(float _velocity)
{
if (_velocity > 0.3f)
{
spriteRenderer.flipX = false;
}
else if (_velocity < -0.1f)
{
spriteRenderer.flipX = true;
}
}
void Flip(float _velocity)
{
if (_velocity > 0.3f)
{
spriteRenderer.flipX = false;
}
else if (_velocity < -0.1f)
{
spriteRenderer.flipX = true;
}
}
after it was not working so i used this: gameobject.transform.setparent() but still no idk
12 Replies
Pobiega
Pobiega8mo ago
This sounds like an issue for $unity
Pobiega
Pobiega8mo ago
When it comes to engine internals or how to use unitys classes properly, thats a better source than here - we can help with the C# aspects of your code, but not with unity internals
MrZone
MrZone8mo ago
i realy think the problem is my code, i mean my code is wrong for sure
Pobiega
Pobiega8mo ago
Well sure, but only someone who knows unity can tell how to fix it
MrZone
MrZone8mo ago
its not an C# issue ?
Pobiega
Pobiega8mo ago
I'm a very experienced C# dev, but know nothing about unity. I have no idea what flipx = false would do on a spriterenderer
MrZone
MrZone8mo ago
ho ok In c# code if you would flip something with a method how would you do it ?
Pobiega
Pobiega8mo ago
Depends entirely on what "something" is
MrZone
MrZone8mo ago
like an object
Pobiega
Pobiega8mo ago
there is no generic answer you can't flip object it has no concept of position or facing this is why this is a unity question
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.