Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a flexible laser?
- Grigos
-
45 posts
How to make a flexible laser?
To be more specific, its a laser that instantly connects from the enemy to the player.
Something like this:
https://youtu.be/i6GKsHigAQM?t=26
The problem is how do I make it longer or shorter depending on where the player is?
Something like this:
https://youtu.be/i6GKsHigAQM?t=26
The problem is how do I make it longer or shorter depending on where the player is?
- Grigos
-
45 posts
How to make a flexible laser?
More detail:
- Enemy spawns, creates a line/sprite instantly connecting from the enemy to the player's character x,y
- It does not follow the player's character
- Ghost effect slowly reaching 100 or animated sprite
- Enemy spawns, creates a line/sprite instantly connecting from the enemy to the player's character x,y
- It does not follow the player's character
- Ghost effect slowly reaching 100 or animated sprite
- ResExsention
-
1000+ posts
How to make a flexible laser?
Okay.
First, create a laser sprite.
Next, in the enemy code, you need to create a clone of the laser and position that clone so that one end is touching the enemy and the other end is going off the screen. Keep it like that for about 0.5 seconds then delete that clone
Then, in the player code just set it in a way so that if the player is touching the laser clone, kill it.
Can't be that hard…
Anyway, should the video be there? This is a kids website, after all. Idk, I'll let someone else handle it.
First, create a laser sprite.
Next, in the enemy code, you need to create a clone of the laser and position that clone so that one end is touching the enemy and the other end is going off the screen. Keep it like that for about 0.5 seconds then delete that clone
Then, in the player code just set it in a way so that if the player is touching the laser clone, kill it.
Can't be that hard…
Anyway, should the video be there? This is a kids website, after all. Idk, I'll let someone else handle it.
Last edited by ResExsention (May 10, 2019 16:33:02)
- Grigos
-
45 posts
How to make a flexible laser?
Okay.
First, create a laser sprite.
Next, in the enemy code, you need to create a clone of the laser and position that clone so that one end is touching the enemy and the other end is going off the screen. Keep it like that for about 0.5 seconds then delete that clone
Then, in the player code just set it in a way so that if the player is touching the laser clone, kill it.
Can't be that hard…
Anyway, should the video be there? This is a kids website, after all. Idk, I'll let someone else handle it.
But why would the other end go off screen?
I want the enemy to laser the player, so, the laser will be starting from the enemy's weapon and ending on the player, but without the laser moving, it just appears and disappears.
Problem is how do I control how long it is
Now I understand what you meant, but this way I'd have to animate it getting longer until it reaches the player's x,y
Last edited by Grigos (May 10, 2019 19:41:13)
- ResExsention
-
1000+ posts
How to make a flexible laser?
You don't have to animate it, actually.
The reason why I suggested letting it go offscreen was to make it look like the player got cut in half (hit) or it just missed (missed).
I think the way the laser acts if it's a miss is fine, but if you want it to stop at the player, you should instead scrap my previous idea and create a small laser bolt. Then, use scripts to move it in a way that makes it move so fast that it looks like the laser was just one long beam. If it hits the player use:
To make the beam disappear. And again, use clones.
The reason why I suggested letting it go offscreen was to make it look like the player got cut in half (hit) or it just missed (missed).
I think the way the laser acts if it's a miss is fine, but if you want it to stop at the player, you should instead scrap my previous idea and create a small laser bolt. Then, use scripts to move it in a way that makes it move so fast that it looks like the laser was just one long beam. If it hits the player use:
To make the beam disappear. And again, use clones.
- StrangeMagic32
-
1000+ posts
How to make a flexible laser?
Do you want a laser like these?
https://scratch.mit.edu/projects/183157839/
https://scratch.mit.edu/projects/170343781/
https://scratch.mit.edu/projects/183157839/
https://scratch.mit.edu/projects/170343781/
- Grigos
-
45 posts
How to make a flexible laser?
I'd probably get it to work if I took StrangeMagic32's laser and made it stop at the players first X,Y
But I never used the pen and won't bother learning it just for this
I'll just make a laser sprite go from the enemy to offscreen in the direction of the player.
But I never used the pen and won't bother learning it just for this
I'll just make a laser sprite go from the enemy to offscreen in the direction of the player.
Last edited by Grigos (May 11, 2019 13:35:14)
- Grigos
-
45 posts
How to make a flexible laser?
Note, my first idea was that the laser would not miss.
It would just connect from the enemy to the player's X.Y at the time, stop there and slowly disappear.
It would just connect from the enemy to the player's X.Y at the time, stop there and slowly disappear.
- Tallented-Code-bot
-
100+ posts
How to make a flexible laser?
if the player and enemy were separate sprites, what you should do is this.
Make a costume in the enemy for the laser. When the laser is triggered, create a clone of the enemy.l
When the enemy is cloned, the clone changes its costume to laser, points toward the player, and
keeps moving forward until it either hits the player or hits the edge. If the player does not move while the laser isl going forward,
it should always hit the player.
Hope that helped
Make a costume in the enemy for the laser. When the laser is triggered, create a clone of the enemy.l
When the enemy is cloned, the clone changes its costume to laser, points toward the player, and
keeps moving forward until it either hits the player or hits the edge. If the player does not move while the laser isl going forward,
it should always hit the player.
Hope that helped
- Grigos
-
45 posts
How to make a flexible laser?
if the player and enemy were separate sprites, what you should do is this.
Make a costume in the enemy for the laser. When the laser is triggered, create a clone of the enemy.l
When the enemy is cloned, the clone changes its costume to laser, points toward the player, and
keeps moving forward until it either hits the player or hits the edge. If the player does not move while the laser isl going forward,
it should always hit the player.
Hope that helped
That's not the point.
Shooting a laser that moves until it hits the player is easy.
What I want:
1) Enemy spawns
2) A line connecting the enemy and the player's X,Y appears.
3) The line slowly disappears.
It's not supposed to miss. It's not supposed to keep going until it hits the edge.
Last edited by Grigos (May 11, 2019 14:04:00)
- ResExsention
-
1000+ posts
How to make a flexible laser?
if the player and enemy were separate sprites, what you should do is this.
Make a costume in the enemy for the laser. When the laser is triggered, create a clone of the enemy.l
When the enemy is cloned, the clone changes its costume to laser, points toward the player, and
keeps moving forward until it either hits the player or hits the edge. If the player does not move while the laser isl going forward,
it should always hit the player.
Hope that helped
That's not the point.
Shooting a laser that moves until it hits the player is easy.
What I want:
1) Enemy spawns
2) A line connecting the enemy and the player's X,Y appears.
3) The line slowly disappears.
It's not supposed to miss. It's not supposed to keep going until it hits the edge.
You're saying it should go up to the edge, but if it hits something (like the player) it deals damage and then fades without ever actually hitting the edge?
- Grigos
-
45 posts
How to make a flexible laser?
if the player and enemy were separate sprites, what you should do is this.
Make a costume in the enemy for the laser. When the laser is triggered, create a clone of the enemy.l
When the enemy is cloned, the clone changes its costume to laser, points toward the player, and
keeps moving forward until it either hits the player or hits the edge. If the player does not move while the laser isl going forward,
it should always hit the player.
Hope that helped
That's not the point.
Shooting a laser that moves until it hits the player is easy.
What I want:
1) Enemy spawns
2) A line connecting the enemy and the player's X,Y appears.
3) The line slowly disappears.
It's not supposed to miss. It's not supposed to keep going until it hits the edge.
You're saying it should go up to the edge, but if it hits something (like the player) it deals damage and then fades without ever actually hitting the edge?
Forget the edge. The laser is never supposed to interact with it
Even if it misses the players character/sprite, it stops at their first X,Y (The players X,Y when the laser appeared)
Also why am I not receiving notifications even with this thread followed
Last edited by Grigos (May 11, 2019 14:22:42)
- Grigos
-
45 posts
How to make a flexible laser?
Also also there is nothing to discuss anymore, the way I want it to work would have to include the pen feature and I'm not planning on learning that.
So I'll just make a bigass laser go offscreen and be done with it
So I'll just make a bigass laser go offscreen and be done with it
Last edited by Grigos (May 11, 2019 14:25:47)
- StrangeMagic32
-
1000+ posts
How to make a flexible laser?
Does this work for you?
https://scratch.mit.edu/projects/308817925/
https://scratch.mit.edu/projects/308817925/
- LittleBitMore
-
100+ posts
How to make a flexible laser?
You could use this code:
You could make the player ALSO receive the broadcast and do something accordingly (such as take damage or die).
Hope it works for you!
The effect results in the laser always hitting the player, always pointing at the player, and always manage to contact the player every single time it fires, and will remain tracking the player for a little bit until it fades out. There is no chance of not hitting the player. If you want it to slowly progress towards the player, or interact with walls, share the project and I'll remix it with the laser code (both of those are just too big and complex to fit well into these discuss posts)
You could make the player ALSO receive the broadcast and do something accordingly (such as take damage or die).
Hope it works for you!
Last edited by LittleBitMore (May 11, 2019 14:50:36)
- Grigos
-
45 posts
How to make a flexible laser?
Does this work for you?
https://scratch.mit.edu/projects/308817925/
Whoops! Our server is Scratch'ing its head
You could use this code:The effect results in the laser always hitting the player, always pointing at the player, and always manage to contact the player every single time it fires, and will remain tracking the player for a little bit until it fades out. There is no chance of not hitting the player. If you want it to slowly progress towards the player, or interact with walls, share the project and I'll remix it with the laser code (both of those are just too big and complex to fit well into these discuss posts)
You could make the player ALSO receive the broadcast and do something accordingly (such as take damage or die).
Hope it works for you!
I'll try it and update you.
- Grigos
-
45 posts
How to make a flexible laser?
@LittleBitMore
Yeah that's it.
I was going to change the go to player to go to player's first X,Y, since the laser wasnt supposed to follow them.
But I like it and I'll leave it as is and credit you.
My question is, would it be possible to do something like this but with a sprite instead? It'd look better animated
Yeah that's it.
I was going to change the go to player to go to player's first X,Y, since the laser wasnt supposed to follow them.
But I like it and I'll leave it as is and credit you.
My question is, would it be possible to do something like this but with a sprite instead? It'd look better animated
Last edited by Grigos (May 11, 2019 15:55:12)
- ResExsention
-
1000+ posts
How to make a flexible laser?
@LittleBitMore
Yeah that's it.
I was going to change the go to player to go to player's first X,Y, since the laser wasnt supposed to follow them.
But I like it and I'll leave it as is and credit you.
My question is, would it be possible to do something like this but with a sprite instead? It'd look better animated
If you're looking for glowy lasers, then you're kind of out of luck in Scratch. Only more powerful engines can have surface light components, or maybe it'd just be too complicated for the young people.
Well, you could use a sprite, however the biggest problem there is making the laser not continue past the player.
Well, my suggestion is this. If you are unable to make one super fast laser that looks like it's just one beam, try instead creating a lot of clones that don't have ends (so that they fit together nicely) and then just release an entire volley of them in a line, deleting those clones as they leave the game area or hit an object.
Wow, making workarounds for an engine that doesn't support particle effects is difficult…
- Grigos
-
45 posts
How to make a flexible laser?
@LittleBitMore
Yeah that's it.
I was going to change the go to player to go to player's first X,Y, since the laser wasnt supposed to follow them.
But I like it and I'll leave it as is and credit you.
My question is, would it be possible to do something like this but with a sprite instead? It'd look better animated
If you're looking for glowy lasers, then you're kind of out of luck in Scratch. Only more powerful engines can have surface light components, or maybe it'd just be too complicated for the young people.
Well, you could use a sprite, however the biggest problem there is making the laser not continue past the player.
Well, my suggestion is this. If you are unable to make one super fast laser that looks like it's just one beam, try instead creating a lot of clones that don't have ends (so that they fit together nicely) and then just release an entire volley of them in a line, deleting those clones as they leave the game area or hit an object.
Wow, making workarounds for an engine that doesn't support particle effects is difficult…
Yes multiple animated clones to make a perfect laser would be an option
- StrangeMagic32
-
1000+ posts
How to make a flexible laser?
sorry my bad, sharedDoes this work for you?
https://scratch.mit.edu/projects/308817925/
Whoops! Our server is Scratch'ing its head
- Discussion Forums
- » Help with Scripts
-
» How to make a flexible laser?