Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need Help Animating Clones
- 4xdblack
-
4 posts
Need Help Animating Clones
I'm creating a very simple RPG game for fun along with two of my friends who are each creating their own game.
For the most part I've just followed various tutorials, changing bits and pieces along the way.
Right now I'm trying to figure out how to animate clones.
The clones are meant to spawn three or less at a time once the player reaches a new area. In this case, my mobs are ninjas, so obviously they need animation.
I tried creating an animated sprite and overlaying it on top of the clones, but that bogged everything down to a pitiable mess.
Then I tried tracking the movement of the clones, and then I could simply reuse the script for my player's animation. But I couldn't find a decent way to track the movement. The idea would be, if (x-position > last x-position) then set direction to right. ect ect. But then that wouldn't account for the idle position.
Finally, my last idea is to simply create three duplicate ninja sprites, which reset after each area. Hiding and showing instead of spawning and deleting.
Any suggestions?
Thanks!
For the most part I've just followed various tutorials, changing bits and pieces along the way.
Right now I'm trying to figure out how to animate clones.
The clones are meant to spawn three or less at a time once the player reaches a new area. In this case, my mobs are ninjas, so obviously they need animation.
I tried creating an animated sprite and overlaying it on top of the clones, but that bogged everything down to a pitiable mess.
Then I tried tracking the movement of the clones, and then I could simply reuse the script for my player's animation. But I couldn't find a decent way to track the movement. The idea would be, if (x-position > last x-position) then set direction to right. ect ect. But then that wouldn't account for the idle position.
Finally, my last idea is to simply create three duplicate ninja sprites, which reset after each area. Hiding and showing instead of spawning and deleting.
Any suggestions?
Thanks!
- deck26
-
1000+ posts
Need Help Animating Clones
I don't really understand what you mean. If you clone a sprite and give it the scripts it will be animated so why do you need to overlay an animated sprite?
- 4xdblack
-
4 posts
Need Help Animating Clones
I don't really understand what you mean. If you clone a sprite and give it the scripts it will be animated so why do you need to overlay an animated sprite?
The animation needs to change depending on what direction it's running, as well as when it stops. And the direction it runs depends on the player. But there are three clones in randomixed positions, so each one will be running a different direction.
Last edited by 4xdblack (Nov. 20, 2018 11:37:05)
- Vicream_Creator
-
100+ posts
Need Help Animating Clones
RPG game for fun along with two of my friends who are each creating their own game.Well the insert the animations in the “original” sprite, and create the clones. With their ID, you fix the basic animation (idle,..?), and depending on their status (walking,…) and their ID/first costume, you make it look like they're running I'm creating a very simple
For the most part I've just followed various tutorials, changing bits and pieces along the way.
Right now I'm trying to figure out how to animate clones.
The clones are meant to spawn three or less at a time once the player reaches a new area. In this case, my mobs are ninjas, so obviously they need animation.
I tried creating an animated sprite and overlaying it on top of the clones, but that bogged everything down to a pitiable mess.
Then I tried tracking the movement of the clones, and then I could simply reuse the script for my player's animation. But I couldn't find a decent way to track the movement. The idea would be, if (x-position > last x-position) then set direction to right. ect ect. But then that wouldn't account for the idle position.
Finally, my last idea is to simply create three duplicate ninja sprites, which reset after each area. Hiding and showing instead of spawning and deleting.
Any suggestions?
Thanks!
- deck26
-
1000+ posts
Need Help Animating Clones
Shouldn't matter. A clone could easily have a set of costumes to cycle through. https://scratch.mit.edu/projects/173573727/ shows one way to do this.I don't really understand what you mean. If you clone a sprite and give it the scripts it will be animated so why do you need to overlay an animated sprite?
The animation needs to change depending on what direction it's running, as well as when it stops. And the direction it runs depends on the player. But there are three clones in randomixed positions, so each one will be running a different direction.
Remember each clone has its own copy of any variables which are ‘for this sprite only’.
- LittleJimmy12
-
27 posts
Need Help Animating Clones
Set the clones to have the animation frames as a set of different costumes. When you enter the area, broadcast a message to start cloning the ninjas.
- 4xdblack
-
4 posts
Need Help Animating Clones
How can I track which direction the sprite clones are going on the xy axis? If I can set a direction variable (right/left/up/down) based on that, then I should be able to animate the rest using the same script for my player sprite.
Edit: should also mention that the rotational style is horizontal.
Edit: should also mention that the rotational style is horizontal.
Last edited by 4xdblack (Nov. 21, 2018 02:13:37)
- 4xdblack
-
4 posts
Need Help Animating Clones
Okay I figured out how to track the direction of the sprite, thus activating the animation.
https://i.gyazo.com/0fefc9ad8b0b460e821765cbf2c6eaa4.mp4
But now I need to know how to track when the sprite stops moving, so it activates the idle position.. In addition, I'll need to animate an attack action for when the sprite gets to a certain distance from the player, but that should be easier to script once I figure out the first problem.
https://i.gyazo.com/0fefc9ad8b0b460e821765cbf2c6eaa4.mp4
But now I need to know how to track when the sprite stops moving, so it activates the idle position.. In addition, I'll need to animate an attack action for when the sprite gets to a certain distance from the player, but that should be easier to script once I figure out the first problem.
Last edited by 4xdblack (Nov. 21, 2018 03:49:01)
- deck26
-
1000+ posts
Need Help Animating Clones
Anything you can do with a sprite you can generally do with a clone. If you'd use a variable to record what a sprite is doing you can do the same with a clone as long as you use a local variable so each clone has its own copy.
So what makes a ninja stop moving? Is it just the distance?
In pseudo code that would just be
forever
if distance too big
switch to idle costume
repeat until distance is within limit
point towards player
end repeat
end if
movement script for one move including custom block to pick next costume
end forever
So what makes a ninja stop moving? Is it just the distance?
In pseudo code that would just be
forever
if distance too big
switch to idle costume
repeat until distance is within limit
point towards player
end repeat
end if
movement script for one move including custom block to pick next costume
end forever
- Discussion Forums
- » Help with Scripts
-
» Need Help Animating Clones