Skip to content

From Value Extensions #248

@EddieCameron

Description

@EddieCameron

This repo is great, especially with the "native" async/awaitable/cancellation token handling, but I really miss some of the other tweening library APIs that make it easy to tween from the current value to a target.
Eg Dotweens: transform.DOPositionTo(targetValue, duration) method.

I've made an extension methods to do something similar in LitMotion:

public static MotionHandle LMPositionTo( this Transform transform, 
        Vector3 targetPosition, 
        float duration, 
        Action<MotionBuilder<Vector3, NoOptions, Vector3MotionAdapter>> addSettingsCallback = null ) {

            var motionBuilder = LMotion.Create( transform.position, targetPosition, duration );
            addSettingsCallback?.Invoke( motionBuilder );
            return motionBuilder.BindToPosition( transform );
}

Which can be called like:

transform.LMPositionTo(  Vector3.zero, 5f )

or

transform.LMPositionTo(  Vector3.zero, 5f, m => m.WithEase( Ease.OutCubic ) )

But it's a bit clunky having to workaround the current API. Would be great to have something similar (or at least a From binding) built in! If not, hope this helps someone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions