Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

dariuspranskus

2
Posts
A member registered Dec 01, 2019

Recent community posts

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       

(1 edit)

First I would like to thank for the asset. I have a question though. Would it be possible to control the change of the variable on each step? So basically I would like to give to the tweener the time/steps and ease control but keep the changing of the variable, for example in a tween step callback script. That script would accept start and end position, duration and progress of a particular tween execution and would set/return the tweening variable value for the particular step (similarly like the To method in DOTween library for unity, if you are familiar).

Thank you

Darius