Unable to configure the Shake
c3-hoge-fuga-piyo opened this issue · comments
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>'.
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?
Unity 2022.3.22f1
OS: Windows 11 Pro (22H2)
commit: 64796c9
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.