To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/ChaffGames . The first 200 of you will get 20% off Brilliant’s annual premium subscription.
That bit at the end where you show how to use tweens to make smooth camera following is a golden drop of game juice. Putting it in any game that emphasizes movement flow makes any project just feel more professional and fun.
For the moving platform you should be able to use an AnimatableBody3D instead of character body - seems like you were trying to find something closer to staticbody
why all godot developers refuse to use the godot naming convention ? PascalCase for class names, singletons and constants . snake_case for everything else . What even is "Camera_Tween" ? Snake_Pascal_Case?
Yes. You’ll find people either indifferent or against this practice. From what I’ve researched it doesn’t seem to affect performance and it is not stated anywhere in the documentation that you shouldn’t do it. But of course you can achieve the exact same result with a lerp function.
I think global position is a derived value so that’s why it doesn’t work. Instead you could get the global position of both your start and end position then calculate the relative distance between them. Then you can tween your position to the current position + the relative distance.
Would this work for character walk cycles? Like I make a sprite and draw in a couple key frames - could I use this to get the in-between frames generated in code?
You could use a tween to the frame of a sprite2d easily. But it won't interpolate what doesn't exist. For example you could use this to switch between two frames. var tween = get_tree().create_tween() tween.tween_method(Sprite.set_frame,0,5,1) And this will cycle between frames 1-5 over 1 second. thanks,
Hey chaff would you help me. If we use navigation enemy automatically finds us but I don't want it.i want that when my player enters enemy's area enemy should follow and hit the player
Hi can you guide me for what am sourcing for let me explen. I really want to make a vector2d rig Game with procedural small animetion just like you said in the vidoe with tweet. Am useing blender to make the 2d meshes and import them into godot it works really well but I want line art on my mesh just like any 2d vector software that uses 2d vectors to form shape it also has strokes for lineart and I need thst in my rigs. I can't import strokes in godot so I have to make them in godot with wail animating foes strokes but the are no guide or sources telling me how I can make this possible. My English is messy but I hope you can still help me I really want to make this projact real.
I really don't get how creating a tween each time you want to use it is better than the old persistant tween reference. i had to make a function to avoid writing all that over and over again perhaps it's better under the hood but i don't like it :p
I understand what he means. And I agree to a certain extent. I even briefly mention that in the video before doing the camera that way. I haven’t seen anything in the documentation that specifically forbids though.
OMG this could be it. Might allow my to increase my onscreen npc limit from 3k to like 10k smoothly. The moveTo function + delay is killing me atm when many are onscreen. I think using tweens I can chuck out so much unnecessary processing. My first game is simulating many npcs offscreen pretty well, but zooming out is a no go atm even with renderServer: ruclips.net/video/_N237bkziEs/видео.html Here's one I did for fun when I was still figuring out the basics in godot (still am) ruclips.net/video/fICuRk69pq8/видео.html I spawned like 2k npcs from a building =P
Interesting, let me know if it improves anything. I’ve found that the bottle neck for a lot of npcs can be collision checks. But I haven’t delved into it that deeply.
@Chaff_Games Oh yeah these are just node2Ds driven by logic. I've stripped everything could from them. I'm not worring about collisions they get paths from an astargrid that has where solid structures are. And they have a dictionary of xy keys with arrays of current entities on the cell. So they can check their immediatr surrounding fast enough. For finding nearest im subscribing static structures to a quadtree spatial partitioner. It's all new to me I've only been using godot/making games for a month. But I got a little code experience. Oh I should mention it did help! I replaced the old logic for moving to a target position with tweens and i went from processing 2.5k onscreen entities (smooth movement) to about 5k before dropping below 60fps using tweens.
I don't think using a tween for the interpolated camera is a good idea, you're destroying and creating a new Tween every frame which is going to create a lot of memory fragmentation. It would be heaps(hah, get it? #programmerpun) better to do the rest of the math and use look_at.
It's good question. I actually don't know how Godot handles the tweens under the hood and if this is bad at a lower level. Of course it's only an example you don't have to do it this way, but nothing else will get the smooth movement.
@@Chaff_Games You can get smooth movement by using interpolate_with() where the weight parameter is just your sine easing function, 1 - Math.cos((x * Math.PI) / 2). You just have to reset x whenever the target position changes and increment it by delta otherwise(until you get to 1, for a 1 second ease, divide 1 by your ease time to slow it down/speed it up). Right now, what you're doing is creating a tween, using the tween to move very slightly to "catch up" with the target and then throwing the tween away and creating a new one on the next frame. You only get the smooth movement when the target has stopped moving which is when your sine ease takes over. Maybe Godot pools Tweens so it's not so harsh on memory but I haven't found anything in the docs to suggest it.
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/ChaffGames . The first 200 of you will get 20% off Brilliant’s annual premium subscription.
That bit at the end where you show how to use tweens to make smooth camera following is a golden drop of game juice. Putting it in any game that emphasizes movement flow makes any project just feel more professional and fun.
Oh, wow! That camera zoom and rotation is great! I've been thinking about looking further into tweens because they seem so useful. Great video!!
My team and I were just leaning into this subject! How wonderful that the next day you upload this video. Thank you and keep up the good work :D !
For the moving platform you should be able to use an AnimatableBody3D instead of character body - seems like you were trying to find something closer to staticbody
Oh cool I will give that a try
Your tutorials are fantastic, mate 🦖 THANKS
oh my god i need the camera section of this! thank you!!
why all godot developers refuse to use the godot naming convention ?
PascalCase for class names, singletons and constants . snake_case for everything else .
What even is "Camera_Tween" ? Snake_Pascal_Case?
It’s just letters bro, they can’t hurt you.
thanks man! really useful tuto.. I'm already using tweens a lot.. but you exposed a lot of details I didnt know :)
Don’t make me tween my mouse cursor to the like button! Whatever that means!
You can tween a mouse cursor to the like button, but you can't make it click (without the proper code of course)
practical and great thank you
i have opted to use cubic bezier instead of the built-in easing equations in my custom build.
Sounds awesome
Good video!
Nice video
so in the camera interpolation code, you are making a new tween object every frame basically?
Yes. You’ll find people either indifferent or against this practice. From what I’ve researched it doesn’t seem to affect performance and it is not stated anywhere in the documentation that you shouldn’t do it. But of course you can achieve the exact same result with a lerp function.
One thing I couldn't make it to work was for global position
I think global position is a derived value so that’s why it doesn’t work. Instead you could get the global position of both your start and end position then calculate the relative distance between them. Then you can tween your position to the current position + the relative distance.
Would this work for character walk cycles?
Like I make a sprite and draw in a couple key frames - could I use this to get the in-between frames generated in code?
You could use a tween to the frame of a sprite2d easily. But it won't interpolate what doesn't exist. For example you could use this to switch between two frames.
var tween = get_tree().create_tween()
tween.tween_method(Sprite.set_frame,0,5,1)
And this will cycle between frames 1-5 over 1 second.
thanks,
@@Chaff_Games Awesome - that sounds great. Thanks for the response :)
i've said it before but ily
☺️
Hey chaff would you help me. If we use navigation enemy automatically finds us but I don't want it.i want that when my player enters enemy's area enemy should follow and hit the player
Hey there, i don’t really understand what you’re asking about but jump on the discord and we can talk there
Hi can you guide me for what am sourcing for let me explen.
I really want to make a vector2d rig
Game with procedural small animetion just like you said in the vidoe with tweet.
Am useing blender to make the 2d meshes and import them into godot it works really well but I want line art on my mesh just like any 2d vector software that uses 2d vectors to form shape it also has strokes for lineart and I need thst in my rigs.
I can't import strokes in godot so I have to make them in godot with wail animating foes strokes but the are no guide or sources telling me how I can make this possible.
My English is messy but I hope you can still help me I really want to make this projact real.
👍
I really don't get how creating a tween each time you want to use it is better than the old persistant tween reference.
i had to make a function to avoid writing all that over and over again perhaps it's better under the hood but i don't like it :p
I was an odd change. I will admit that I didn’t like it at first either.
You use a Tween when you want a multi frame transition *without relying on _process*. If do it in _process, you might as well use lerp! 😂
Yep, lerp is totally fine. But this video is about teeens.
@@Chaff_Games he means that you'd use tweens if you didn't want to depend on _process functions. doing tweens in _processes defeat the purpose
I understand what he means. And I agree to a certain extent. I even briefly mention that in the video before doing the camera that way. I haven’t seen anything in the documentation that specifically forbids though.
OMG this could be it.
Might allow my to increase my onscreen npc limit from 3k to like 10k smoothly.
The moveTo function + delay is killing me atm when many are onscreen.
I think using tweens I can chuck out so much unnecessary processing.
My first game is simulating many npcs offscreen pretty well, but zooming out is a no go atm even with renderServer:
ruclips.net/video/_N237bkziEs/видео.html
Here's one I did for fun when I was still figuring out the basics in godot (still am)
ruclips.net/video/fICuRk69pq8/видео.html
I spawned like 2k npcs from a building =P
Interesting, let me know if it improves anything. I’ve found that the bottle neck for a lot of npcs can be collision checks. But I haven’t delved into it that deeply.
@Chaff_Games Oh yeah these are just node2Ds driven by logic. I've stripped everything could from them.
I'm not worring about collisions they get paths from an astargrid that has where solid structures are.
And they have a dictionary of xy keys with arrays of current entities on the cell.
So they can check their immediatr surrounding fast enough.
For finding nearest im subscribing static structures to a quadtree spatial partitioner.
It's all new to me I've only been using godot/making games for a month. But I got a little code experience.
Oh I should mention it did help!
I replaced the old logic for moving to a target position with tweens and i went from processing 2.5k onscreen entities (smooth movement) to about 5k before dropping below 60fps using tweens.
I don't think using a tween for the interpolated camera is a good idea, you're destroying and creating a new Tween every frame which is going to create a lot of memory fragmentation. It would be heaps(hah, get it? #programmerpun) better to do the rest of the math and use look_at.
It's good question. I actually don't know how Godot handles the tweens under the hood and if this is bad at a lower level. Of course it's only an example you don't have to do it this way, but nothing else will get the smooth movement.
@@Chaff_Games You can get smooth movement by using interpolate_with() where the weight parameter is just your sine easing function, 1 - Math.cos((x * Math.PI) / 2). You just have to reset x whenever the target position changes and increment it by delta otherwise(until you get to 1, for a 1 second ease, divide 1 by your ease time to slow it down/speed it up). Right now, what you're doing is creating a tween, using the tween to move very slightly to "catch up" with the target and then throwing the tween away and creating a new one on the next frame. You only get the smooth movement when the target has stopped moving which is when your sine ease takes over. Maybe Godot pools Tweens so it's not so harsh on memory but I haven't found anything in the docs to suggest it.