8 Comments
User's avatar
Jake's avatar

I am also making a top down shooter (very early prototype still) and knew that I needed to get my movement out of the individual player/enemy scripts, just a little work and I was able to get my movement system in components using this method. Thank you for the quick guide it was extremely helpful and straightforward!

Selfishly, I am gonna start working on enemy AI and context based steering for my game soon, just in case you needed ideas for the next one 😅

Expand full comment
bewn N. web's avatar

thank you. While not a complete newb, I was just a tad bit coRnfused.

thanks for taking the time to answer.

Expand full comment
Heartbeast's avatar

You're welcome! Sorry for the discrepancy in the names.

Expand full comment
Dave's avatar

Thanks for the quick and easy example. Just one question, would it make sense to save the whole node with the script attached as a scene? So you don’t have to add a node, rename it, and attach the script every time? Or does that approach have other drawbacks?

Expand full comment
Your Friend, Jonathan's avatar

"Once the scene is set up, don’t forget to set the export variables on the components"

Since your components are children of the nodes they act on, why not do:

`@onready var actor = $".."`

instead of

`@export var actor: CharacterBody2D`

?

It's just one fewer thing you have (and might forget) to plug in, right?

Expand full comment
bewn N. web's avatar

could you please point out where the "character_movement_stats.tres" is made ?

your article says "Once the scene is set up, don’t forget to set the export variables on the components"

but shows "character_movement_stats.tres" NOT "player_movement_stats.tres"

thank you

Expand full comment
Heartbeast's avatar

Hey, thanks for the comment. The screenshot shows character_movement_stats.tres but that is a mistake, just use player_movemement_stats.tres instead (what it is named doesn't actually matter, it could be named anything, and it would still work).

Expand full comment
Johnny's avatar

Thanks Ben, saved for later!

Expand full comment