Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a computer controlled character?I need help!
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
I am working on a fighting game that will have a 2 player mode along with a mode where you fight a computer controlled character.Does anyone know how to program the computer controlled character?
- TheAwesomeMaster
-
1000+ posts
How to make a computer controlled character?I need help!
This is one of the most basic options, there are some more complicated ones too.
- deck26
-
1000+ posts
How to make a computer controlled character?I need help!
The computer controlled character will presumably want to move towards the player and it may be useful for it to know how close it is. So the following blocks might be useful.
It becomes more complicated if there are obstacles that the attacker has to go round.
- Ermagerd117
-
19 posts
How to make a computer controlled character?I need help!
Try doing this for smooth movement
If you need anything else, Don't be afraid to ask!
If you need anything else, Don't be afraid to ask!
Last edited by Ermagerd117 (Oct. 12, 2015 15:07:52)
- deck26
-
1000+ posts
How to make a computer controlled character?I need help!
There's no point giving scripts controlled by key presses for the computer controlled character!
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
The computer controlled character will presumably want to move towards the player and it may be useful for it to know how close it is. So the following blocks might be useful.It becomes more complicated if there are obstacles that the attacker has to go round.
There are obstacles like ledges and floating platforms.
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
Try doing this for smooth movement
If you need anything else, Don't be afraid to ask!
Thanks!
Do you know how to program when someone takes a hit,they lose health?
- MegaApuTurkUltra
-
1000+ posts
How to make a computer controlled character?I need help!
Basic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these states
So an example game might go like
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these states
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go like
Player hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
Basic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these statesThe triggers for each would be
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
Triggers can also just be random, eg if you have a bunch of different types of moves for your fighting game then you'll need to choose a random one.
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go likePlayer hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
I am actually doing this as a collab so is it okay if i copy and paste this post to my collab members?
- deck26
-
1000+ posts
How to make a computer controlled character?I need help!
The forum is open to all users to read so there can be no objection to that.Basic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these statesThe triggers for each would be
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
Triggers can also just be random, eg if you have a bunch of different types of moves for your fighting game then you'll need to choose a random one.
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go likePlayer hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
I am actually doing this as a collab so is it okay if i copy and paste this post to my collab members?
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
The forum is open to all users to read so there can be no objection to that.Basic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these statesThe triggers for each would be
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
Triggers can also just be random, eg if you have a bunch of different types of moves for your fighting game then you'll need to choose a random one.
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go likePlayer hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
I am actually doing this as a collab so is it okay if i copy and paste this post to my collab members?
Thanks!
- MegaApuTurkUltra
-
1000+ posts
How to make a computer controlled character?I need help!
YepBasic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these statesThe triggers for each would be
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
Triggers can also just be random, eg if you have a bunch of different types of moves for your fighting game then you'll need to choose a random one.
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go likePlayer hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
I am actually doing this as a collab so is it okay if i copy and paste this post to my collab members?
- Nehal1234
-
500+ posts
How to make a computer controlled character?I need help!
Thanks!YepBasic AI:
Make the AI 100% perfect, but then add “mistakes” randomly. The amount of “mistakes” determines the difficulty.
Example: If you're making Pong, then make the AI paddle follow the ball perfectly but sometimes make it lag behind or stop all of a sudden.
When to use this: If there is only one thing that the AI needs to do, eg follow the pong ball with their paddle
More complicated AI:
Sophisticated AIs use states, which basically define what the AI is supposed to do at some point. Each state has triggers, which tell the AI when to enter that state, and actions, which are what the AI does when it's in that state.
Example: If you were to make an air hockey game, you might have these statesThe triggers for each would be
- Hit the puck towards the player's goal
- Block an incoming puck
- Go backwards around the puck
- Move around randomly / do nothing
Triggers can also just be random, eg if you have a bunch of different types of moves for your fighting game then you'll need to choose a random one.
- Enter this state if the puck is in front of the AI paddle but on the AI's side
- Enter this state if the puck is on the AI's side, in front of the AI paddle, and going towards the goal
- Enter this state if the puck is on the AI's side but behind the AI paddle
- Enter this state if the puck is in front of the AI, on the enemy side, and going towards the enemy
So an example game might go likePlayer hits puck towards AI goal
AI enters blocking state, successfully blocks puck
AI enters hitting state, hits the puck towards the player goal
AI enters do nothing state while the puck goes towards the player goal
Player blocks the puck and hits it back
AI enters blocking state, fails to block the puck. The puck is now behind the AI
AI enters go backwards state, goes around the puck. The puck is now in front of the AI
AI enters blocking state again, successfully blocks the puck
and so on…
You can add random mistakes to this as well, depending on whether your AI ends up being hard to beat or not.
When to use: When there are multiple things your AI needs to do depending on the environment.
HTH
I am actually doing this as a collab so is it okay if i copy and paste this post to my collab members?
- JokerDeath
-
3 posts
How to make a computer controlled character?I need help!
What if the thing you want the computer to control is a fighting character and that character has to switch sprites and combos/attacks?
- deck26
-
1000+ posts
How to make a computer controlled character?I need help!
Better to start your own new topic rather than necroposting. Share what you have and define what you're trying to achieve. What if the thing you want the computer to control is a fighting character and that character has to switch sprites and combos/attacks?
- BigBrainBuster
-
1 post
How to make a computer controlled character?I need help!
I need block code can anyone help. I need the code to make a cpu that I need in my game it would be awesome if one of you guys can help me.

-Love this chat though

-Love this chat though
Last edited by BigBrainBuster (Oct. 17, 2019 17:40:29)
- deck26
-
1000+ posts
How to make a computer controlled character?I need help!
Please start a new topic rather than necroposting. I need block code can anyone help. I need the code to make a cpu that I need in my game it would be awesome if one of you guys can help me.
-Love this chat though
- lisagu
-
79 posts
How to make a computer controlled character?I need help!
Try doing this for smooth movement
If you need anything else, Don't be afraid to ask!
Thanks!
Do you know how to program when someone takes a hit,they lose health?
Make a variable called ‘'Lives’' ;
At the beginning of the game, set ‘'Lives’' to 0
- help_with_scripts
-
100+ posts
How to make a computer controlled character?I need help!
If touching (enemy) and costume of enemy equals (attack) change health by 0 - (attack strength)Try doing this for smooth movement
If you need anything else, Don't be afraid to ask!
Thanks!
Do you know how to program when someone takes a hit,they lose health?
- Discussion Forums
- » Help with Scripts
-
» How to make a computer controlled character?I need help!