#animation buffer?

182 messages · Page 1 of 1 (latest)

quartz verge
#

when playing one animation and then playing the next animation it seems to make my npc stand up straight for half a second and then it plays the next animation, how do i remove this effect?

local part = script.Parent.Parent.Designated
local animation = script.Animation
local anim2 = script.Anim2
local anim3 = script.anim3
local humanoid = script.Parent.Humanoid
local animationTrack = humanoid:LoadAnimation(animation)
local anim2Track = humanoid:LoadAnimation(anim2)
local anim3Track = humanoid:LoadAnimation(anim3)

local function playNext()
    print("Animation stopped and playing Anim2")
    anim2Track:Play()
    wait(anim2Track.Length)
    anim2Track:Stop()
    print("Anim2 stopped and playing Anim3")
    anim3Track:Play()
end

-- Play the first animation
animationTrack:Play()

local function onTouched(other)
    local character = other.Parent
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")

    -- If touched by a player's humanoid, stop the animation and play Anim2
    if humanoid then
        animationTrack:Stop()
        playNext()
    end
end

part.Touched:Connect(onTouched)
quartz verge
#

Ive tried implementing a wait and also a firstRun bool to where it the first animation will continue to loop and after the player touches the designated part then it will stop the first animation and start the 2nd then the 3rd animation only once and stop at the 3rd animation. The problem is that when the 2nd animation plays, the npc stands straight up and then plays the 2nd animation, also using the print function, the animations are being run multiple times for example its being run 18x and so the head of the npc will look like its bugged and reset from the start of the 2nd animation for a few times before going to the 3rd animation.

local part = script.Parent.Parent.Designated
local animation = script.Animation
local anim2 = script.Anim2
local anim3 = script.anim3
local humanoid = script.Parent.Humanoid
local animationTrack = humanoid:LoadAnimation(animation)
local anim2Track = humanoid:LoadAnimation(anim2)
local anim3Track = humanoid:LoadAnimation(anim3)
local firstRun = true

local function playNext()
    print("Animation stopped and playing Anim2")
    anim2Track:Play()
    wait(anim2Track.Length)
    --anim2Track:Stop()
    print("Anim2 stopped and playing Anim3")
    anim3Track:Play()
end

local function onTouched(other)
    if firstRun == true then
        local character = other.Parent
        local humanoid = character:FindFirstChildWhichIsA("Humanoid")

        -- If touched by a player's humanoid, stop the animation and play Anim2
        if humanoid then
            
            wait(1)
            print("falsing")
            animationTrack:Stop()
                playNext()
                wait(5)
                print("Ran once")
                firstRun = false
            
        end
    end
end

animationTrack:Play()

part.Touched:Connect(onTouched)
surreal patio
#

I've had the same issues before and I don't totally understand it, but my best guesses are that the animation priority is set incorrectly (done via animation editor) or your keyframes are starting from a standing position

#

I've had moments where I got no issues, other times when it was presumably the same script with stuttering, so I dont exactly understand either

#

hope that helps a little bit? theres def someone out here that knows better than me tho

quartz verge
#

im not sure because the starting position is definitely not standing and im not sure what else to do

surreal patio
#

I was just trying to solve the issue formyself and I found something out

#

Let me ask a question, in your animation did you create keyframes of the player's neutral standing pose?

sonic urchinBOT
#

studio** You are now Level 3! **studio

quartz verge
#

let me open studio and check again, ive just woken up

#

none of my keyframes start from standing

surreal patio
#

mind what your trying to animate exactly?

#

ty

quartz verge
#

just from sitting down and looking up a little

surreal patio
#

is this a cutscene?

quartz verge
#

from animation1 > animation2 it suddenly tenses up and then goes back to sitting down to start animation2

quartz verge
surreal patio
#

by tenses up do you mean stutturs

#

like resetting to normal pos then starting again?

quartz verge
#

yes

#

im not sure why the head keyframe dots are orange but maybe that has to do with it a little?

#

im very new to animating as ive just started using studio yesterday

quartz verge
#

im not sure how to remove the orange and make it normal

quartz verge
surreal patio
#

heres what I would try and do

#

make an anim of the dude sitting doen, setting anim priority to idle

#

then make other animations action

#

then you can keep the idle one playing the whole time

#

and the action anims will override

quartz verge
#

does that mean i have to republish them?

#

and whats the difference between idle and core

surreal patio
#

idk

#

I believe they just rank in priority

#

so a core anim will be overridden by any idle animations or anything below idle

#

but if there are no keyframes in the overriding anim (like only the head moves) then the rest of the core anim will play

#

thats how stuff like tools in roblox work

#

they have "action" priority

#

but character anims still play

quartz verge
#

ill try remake the first animation but instead of it being cubic ill make it linear, dont know what the difference is but im just trying to make it work

surreal patio
quartz verge
#

and then republish all animations

#

with that in mind

quartz verge
#

so just republish with new priorities?

surreal patio
#

yes

quartz verge
#

okok

#

it fixed the stutter

#

but

#

it keeps playing the first animation after the 2nd and 3rd animation plays

#

im not sure how to code this much

local part = script.Parent.Parent.Designated
local animation = script.Animation
local anim2 = script.Anim2
local anim3 = script.anim3
local humanoid = script.Parent.Humanoid
local animationTrack = humanoid:LoadAnimation(animation)
local anim2Track = humanoid:LoadAnimation(anim2)
local anim3Track = humanoid:LoadAnimation(anim3)


local function playNext()
    print("Animation stopped and playing Anim2")
    anim2Track:Play()
    wait(anim2Track.Length)
    --anim2Track:Stop()
    print("Anim2 stopped and playing Anim3")
    anim3Track:Play()
end

local function onTouched(other)

    local character = other.Parent
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")

    -- If touched by a player's humanoid, stop the animation and play Anim2
    if humanoid then
        wait(1)
        playNext()
        wait(5)
    end
end


animationTrack:Play()

part.Touched:Connect(onTouched)
surreal patio
#

correct me if I'm wrong

#

the anim is supposed to play for both animations then stop after right?

quartz verge
#

yes

surreal patio
#

@

#

ok then

quartz verge
#

but the first animation will loop play

#

until the player has touched the part

surreal patio
#

wait(anim3Track.Length)

#

so this

#

then anim:Stop()

quartz verge
surreal patio
#

or whatever the looping one is

quartz verge
#

animationTrack is anim 1
anim2Track is anim 2
anim3Track is anim 3

#

if I do animationTrack:Stop() it stutters

surreal patio
#

you just have to call anim1 to stop when they are done

quartz verge
#

when which is done

surreal patio
#

all the ones you want to play before stopping

quartz verge
#

okok ill try that

surreal patio
#

if you want to play 2&3, you make anim1 stop in the code after they've played

quartz verge
#

ok im trying

#

it triggered the idle animation to stop but it keeps playing in the end

#

and it stutters again

#

i think it stutters because animation 1 was called to stop

surreal patio
#

did you call it to stop after anim2?

quartz verge
#
local function playNext()
    anim2Track:Play()
    print("Anim2 playing")
    wait(anim2Track.Length)
    anim2Track:Stop()
    print("Anim2 stopped")
    animationTrack:Stop()
    print("Anim1 stopped")
    anim3Track:Play()
    print("Anim3 playing")
end
surreal patio
#

yes its going to stutter

#

its playing anim2

#

waits until finished

#

stops anim2

#

stops anim1

#

then plays anim3

#

you need anim1 to stop after anim3

quartz verge
#

let me try

sonic urchinBOT
#

studio** You are now Level 4! **studio

quartz verge
#

it still stutters

local function playNext()
    anim2Track:Play()
    print("Anim2 playing")
    wait(anim2Track.Length)
    anim2Track:Stop()
    print("Anim2 stopped")
    anim3Track:Play()
    print("Anim3 playing")
    animationTrack:Stop()
    print("Anim1 stopped")
end
#

and the anim1 still plays

#

the idle animation

#

even after its been called to stop

quartz verge
#

Ive figured it out

#

somehow along the way I managed to accidentally save the 1st animation as the 3rd animation 😐

#

but thank you @surreal patio :)

#

also do yk how to add text on the bottom of the screen like a type writer animation and some type writer font, idk if that uses some gui tricks or just printing on screen im not sure how

surreal patio
#

Ill give you some AI help

#
local playerGui = player:WaitForChild("PlayerGui")

local typewriterLabel = playerGui:WaitForChild("TypewriterLabel")
local textToDisplay = "This is a typewriter animation example in Roblox Lua."
local typingSpeed = 0.05 -- Adjust the typing speed as needed

-- Function to animate the typewriter effect
local function typewriterEffect()
    for i = 1, #textToDisplay do
        typewriterLabel.Text = string.sub(textToDisplay, 1, i)
        wait(typingSpeed)
    end
end

-- Connect the typewriter effect function to the script
typewriterEffect()

-- You can adjust the position, size, font, and other properties of the TypewriterLabel as needed.
#

If your knew to scripting, I'd highly recomment using roblox's documentation, or asking chatgpt detailed questions like, "What does for i = 1, #textToDisplay do Mean?"

quartz verge
#

ah okok tysm

#

ill make sure to try it out later in the evening

surreal patio
#

Is your anim script local

sonic urchinBOT
#

studio** You are now Level 17! **studio

surreal patio
#

You could try :FireAllClients()

#

Because the issue might be its not sending to a specific client

quartz verge
#

yes i did that thank you

#

im sorry I didnt realize you replied

#

how do I just play one second of a specific audio

#

like for example I want to play the audio but only seconds 3-4

surreal patio
#

As far as I know, there's no easy way around it

quartz verge
#

😔

#

the type writer animation doesnt match up with my text

surreal patio
#

Either you make it :Stop() after 1 sec or get a better sound

quartz verge
#

i mean the sound

quartz verge
#

let me see

surreal patio
#

If I were you I'd get a single click sound, literally anything that sounded like a click

#

Dialogue audio is just one note of a sound getting spammed

quartz verge
#

perfcect i found a single second audio of one

surreal patio
#

Cool

#

Lil tip

quartz verge
#

theres some bug with the shift lock tho

#

like when im shift locked it doesnt turn my screen or like when im in first person

#

ive seen it in some games but i have not the slightest idea how to fix it

surreal patio
#

You can easily make a sound start in the middle of a sound or towards the end

#

There's a time length or position property, I forgot the name

#

But it's just in each sound

quartz verge
#

ah okay i see

surreal patio
#

Explain diff

quartz verge
#

let me record a clip of it

#

itll be easier to demonstrate

surreal patio
#

Ok

quartz verge
sonic urchinBOT
#

studio** You are now Level 5! **studio

quartz verge
#

its so hard to move my screen when im shift locked or in first person

#

im not sure why

surreal patio
#

Do you have custom camera movement?

quartz verge
#

not as far as i know

#

idk what those are because i didnt put them in

surreal patio
#

Well if you don't need shift lock then... get rid of it 😎👍

#

I've never come across this issue so idk

quartz verge
#

ah alright no worries then

surreal patio
#

You can see if other ppl get it or if it's just u

quartz verge
#

it just does it in first person as well

surreal patio
#

Like testing in another random game

surreal patio
#

Firstly, test in a fresh baseplate to see if it's a fundamental studio bug, then it's not your fault!

quartz verge
#

what if i test it in the game like i launch roblox

surreal patio
#

If it's working in the baseplate, then it's your issue, one by one disable the local scripts in your game, testing each time. Whenever the issue stops, that'll tell you which script is causing the bug

quartz verge
#

disable local scripts as in commenting them or is there a way to actually disable?

surreal patio
#

It's a property

#

As a payment for me helping you, you should play our game that comes out in the next few days

#

For free rizz

quartz verge
#

of course ill be sure to check it out

#

im trying to disable one by one as much as i can to see

surreal patio
#

Well firstly try disabling all scripts

#

If there's an issue and all scripts are disabled, might be a settings problem?

#

You should still try the fresh baseplate test with all of this too to really narrow it out

quartz verge
#

disabling all scripts didnt seem to help

surreal patio
#

Do the fresh baseplate test

quartz verge
#

okok

#

it works perfect in a fresh baseplate

surreal patio
#

Well I'm afraid your debugging process is gonna be a bit tedious, here's what I would do

#

Start adding things like scripts and the map into the fresh baseplate (doesn't have to be 1 by 1) and just keep testing every time you add a lot of stuff in. Eventually the bug will come into the baseplate, which will then tell you what's causing the issue.

#

There's one other case

#

Which is unlikely

#

If EVERYTHING is in the new baseplate and working just fine

#

Then just start working on the game with the new baseplate crying

#

Cause that other one is damned to just break

quartz verge
#

Imma cry

#

can I at least export the map terrain?

surreal patio
#

Try file + save as then select the baseplate

#

That will directly copy the game into the baseplate

quartz verge
#

okok that wil be my last resort

surreal patio
#

Yeah there are some things you don't have to try, I would do scripts and other game changing stuff first

quartz verge
#

yes ill try that

#

i have given up