Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hi 8BitWarrior. I want to achieve the following. I have an object with triangle shape sprite and I need to rotate an instance of it around any of the vertices depending on the user action. I can not use sprite origin to do that, by dynamically changing the sprite origin and then rotating the sprite, for it will affect the origins of all other instances of the object. But I want to animate that rotation and this means that I need to calculate the instance position and rotation for each step of the move. For that I want the tweener to call my script 30 or 60 times and I will move the instance in code rather than allowing it to lerp between start and end value and move the instance automatically. This i because my trajectory is not  a line, but a curve. My script would accept the instance id, start and end value and the progress value, from them I can calculate the exact position and rotation.

This is easily achievable by DOTWeen library in Unity (http://dotween.demigiant.com/getstarted.php):

Please see the following script (C#):

public static Tween Rotate(Transform target, Vector3 rotationPoint, float angle, float duration)
        {
            var angleRotated = 0f;
            return DOTween.To(
                () => angleRotated,
                newAngle =>
                {
                    // This is a custom function which calculates the position and then moves the object to it
                    GameObjectHelpers.RotateAroundLocal(target, rotationPoint, newAngle - angleRotated);
                    angleRotated = newAngle;
                },
                angle,
                duration
            );

        }

Thanks in advance       

Hey, Darius.

Sorry for the SUPER late reply! Did you ever find a solution to this, or can I still be of any help?

Let me know :)

-Stephen