AnnulusGames / LitMotion

Lightning-fast and Zero Allocation Tween Library for Unity.
https://annulusgames.github.io/LitMotion/
MIT License
828 stars 66 forks source link

Unable to configure the Shake #121

Closed c3-hoge-fuga-piyo closed 6 months ago

c3-hoge-fuga-piyo commented 8 months ago

The document-provided code results in a compilation error even when used as is.

LMotion.Shake.Create(0f, 5f, 2f)
    .WithFrequency(20)
    .WithDampingRatio(0f)
    .WithRandomSeed(123)
    .BindToPositionX(target2);
error CS0315: The type 'LitMotion.Adapters.FloatShakeMotionAdapter' cannot be used as type parameter 'TAdapter' in the generic type or method 'MotionBuilderExtensions.WithFrequency<TValue, TAdapter>(MotionBuilder<TValue, PunchOptions, TAdapter>, int)'. There is no boxing conversion from 'LitMotion.Adapters.FloatShakeMotionAdapter' to 'LitMotion.IMotionAdapter<float, LitMotion.PunchOptions>'.
qwe321qwe321qwe321 commented 8 months ago

This code works on my project (Win10, 2022.3.21f1) with the latest commit in the main branch (package installed from git URL). Perhaps you could provide your Unity version, OS, and the LitMotion version/branch?

c3-hoge-fuga-piyo commented 8 months ago

Unity 2022.3.22f1 OS: Windows 11 Pro (22H2) commit: 64796c9f3886f1374d1e7c72ead3e839bc576825

AnnulusGames commented 6 months ago

The cause of this problem seems to be that the asmdef does not contain a reference to Unity.Mathematics.

It's hard to tell from the compilation error, but the type of ShakeOptions refers to Unity.Mathematics.Random. Therefore, a reference is also required in the asmdef on the side that uses ShakeOptions.

Without this, the appropriate extension method cannot be resolved and a compilation error will result, but since a similar extension method is provided for PunchOptions, it seems that the confusing error is displayed.