ShadowMario / FNF-PsychEngine

Engine originally used on Mind Games mod
Apache License 2.0
1.16k stars 2.22k forks source link

i need help with using tween angle on a sprite #4763

Closed Gavinator96 closed 2 years ago

Gavinator96 commented 2 years ago

Describe your problem here.

so im trying to make a infinite tween thing that makes something turn 45 degrees to the right then 90 degrees to the left so its swinging back and forth but the tweens arent working (im trying to add a pendulum thing i made without using adobe animate to animate the tweens cause i dont have it) image whenever the song starts or anytime during the song, the pendulum thing just isnt turning like at all it just stays still and does nothing btw the image file of the pendulum is just a 1 frame image of a pendulum i made and before you ask, yes im trying to do all of this inside of the lua file of a stage

Are you modding a build from source or with Lua?

Lua

What is your build target?

Windows x64

Did you edit anything in this build? If so, mention or summarize your changes.

i added some other mods into psych engine (vs impostor, sonic exe, shaggy x matt, doki doki takeover, lullaby) and the images and stuff for them like the stages, characters and icons and stuff

frantastic24 commented 2 years ago

Swap the first two strings in your tween, you're supposed to give your tween a tag first (any will do) and then type what object you want to tween, in this case it's 'Pendelum' (you typed the image file for the sprite instead) It should look like this doTweenAngle('swing', 'Pendelum', angle, duration, 'easeInOut') Then if you want to continue tweening it you'll either need to create a loop or use stuff like song position, BPM, etc I'm guessing you're doing something like Lullaby so you can just look at the source code to get a better idea

Gavinator96 commented 2 years ago

Swap the first two strings in your tween, you're supposed to give your tween a tag first (any will do) and then type what object you want to tween, in this case it's 'Pendelum' (you typed the image file for the sprite instead) It should look like this doTweenAngle('swing', 'Pendelum', angle, duration, 'easeInOut') Then if you want to continue tweening it you'll either need to create a loop or use stuff like song position, BPM, etc I'm guessing you're doing something like Lullaby so you can just look at the source code to get a better idea

the 'Pendelum' part is the tag the 'Pendelum thing' is the image file

frantastic24 commented 2 years ago

You tween an object, not an image file

Gavinator96 commented 2 years ago

also i dont know how to use stuff like song position or bpm or whatever and btw i also well dont know how to see source code, im on the lua build

Gavinator96 commented 2 years ago

You tween an object, not an image file

then do i tween the tag that i gave the image

frantastic24 commented 2 years ago

You use source code as reference, it's public and helps a lot

Gavinator96 commented 2 years ago

You use source code as reference, it's public and helps a lot

well i dont know where to find the source code for it

frantastic24 commented 2 years ago

✨✨Google✨✨ it's literally in the mod's gamebanana page

Gavinator96 commented 2 years ago

ok well i dont know what to do with the source code

frantastic24 commented 2 years ago

You read it and you translate it into Lua code

Gavinator96 commented 2 years ago

ok

Gavinator96 commented 2 years ago

Swap the first two strings in your tween, you're supposed to give your tween a tag first (any will do) and then type what object you want to tween, in this case it's 'Pendelum' (you typed the image file for the sprite instead) It should look like this doTweenAngle('swing', 'Pendelum', angle, duration, 'easeInOut') Then if you want to continue tweening it you'll either need to create a loop or use stuff like song position, BPM, etc I'm guessing you're doing something like Lullaby so you can just look at the source code to get a better idea

also btw when i did this it just did this

https://user-images.githubusercontent.com/99510438/153676025-ff660c3d-a72d-4205-9a97-22877dddb45f.mp4

Gavinator96 commented 2 years ago

✨✨Google✨✨ it's literally in the mod's gamebanana page

also the gamebanana page for what? psych engine or lullaby

frantastic24 commented 2 years ago

Because you need to set origin properties setProperty('Pendelum.origin.x', 65), something like this I think, you can see the exact value in the source code

Gavinator96 commented 2 years ago

setProperty('Pendelum.origin.x', 65)

let me rq try that

Gavinator96 commented 2 years ago

Because you need to set origin properties setProperty('Pendelum.origin.x', 65), something like this I think, you can see the exact value in the source code

this works i just had to change it to origin.y', 85 but how do i make it so it for 1, only starts moving when the song starts and for 2, loop back and forth infinitely

frantastic24 commented 2 years ago

also the gamebanana page for what?

You're doing a mechanic from Lullaby, did you forget

Gavinator96 commented 2 years ago

also the gamebanana page for what?

You're doing a mechanic from Lullaby, did you forget

yes i did lol

Gavinator96 commented 2 years ago

Because you need to set origin properties setProperty('Pendelum.origin.x', 65), something like this I think, you can see the exact value in the source code

this works i just had to change it to origin.y', 85 but how do i make it so it for 1, only starts moving when the song starts and for 2, loop back and forth infinitely

im still wondering how to do these 2 things tho

frantastic24 commented 2 years ago

starts moving when the song starts

function onSongStart()

loop back and forth infinitely

Activate another tween after one finishes using function onTweenCompleted(tag), do a thorough read of the psych engine wiki and lullaby source first It's a little too convoluted to explain through here so if you're interested I've already posted a Lua script of this mechanic in discussions

Gavinator96 commented 2 years ago

starts moving when the song starts

function onSongStart()

loop back and forth infinitely

Activate another tween after one finishes using function onTweenCompleted(tag), do a thorough read of the psych engine wiki and lullaby source first It's a little too convoluted to explain through here so if you're interested I've already posted a Lua script of this mechanic in discussions

can you link it

frantastic24 commented 2 years ago

4183

Gavinator96 commented 2 years ago

function onSongStart() doTweenAngle('sleft', 'Pendelum', 45, 1, 'easeInOut') end

function onTweenCompleted(sleft) doTweenAngle('sright', 'Pendelum', -45, 1, 'easeInOut') end

function onTweenCompleted(sright) doTweenAngle('sleft', 'Pendelum', 45, 1, 'easeInOut') end

i added that under the code for the stage and it just swings left then stops

frantastic24 commented 2 years ago

You only need one onTweenCompleted, the (tag) is just to name the function variable, not where you put your tag

function onTweenCompleted(tag) --"tag" can be anything, but tag is just the common name
     if tag == 'sleft' then
          --new tween here
     elseif tag == 'sright' then
          --other tween here
     end
end
frantastic24 commented 2 years ago

Also worth noting that the way tweens work is: it will change the property to what value you give them, and stop there. In other words it will just rotate to 45 degrees and stop, every time

Gavinator96 commented 2 years ago

do you have discord it will be a lot easier to show you what im talking about instead of just typing it all out

Gavinator96 commented 2 years ago

cause when it tweens to swing to the right it doesnt work correctly

frantastic24 commented 2 years ago

Because it's nowhere near how the original tween is done, so of course it will be weird I'm not sharing my discord

yeeterongithub commented 2 years ago

do onCreatePost not onCreate