Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Shooter Game
- GABOCSB18
-
Scratcher
28 posts
Shooter Game
So, I'm making a shooter game, and I'm coding the gun movement, and I have a little problem.
I'm using this script:
Got to X: x position of Player, Y: y position of Player
and When I do that script, it sort of works, except when you move, the gun drags behind a little, can someone please help me?
I'm using this script:
Got to X: x position of Player, Y: y position of Player
and When I do that script, it sort of works, except when you move, the gun drags behind a little, can someone please help me?
- gor-dee
-
Scratcher
1000+ posts
Shooter Game
The reason for this is to do with the order your scripts are running. When you have two or more sprites with forever loops, as I expect you have, the script in the front sprite runs, then the script in the next one back and so on until the sprite at the back. If your gun sprite is in front of your player sprite, as I expect it is, it will move to the player but then the player will move making it appear to lag behind. If you make the gun on a layer behind the player it should work. If you need the gun in front of the player you could try putting a WAIT 0 SECs at the beginning of the forever loop script…
- CaoLuan
-
Scratcher
39 posts
Shooter Game
There are 2 ways that I usually counter this problem.
1. I usually just put the gun sprites in the character sprite itself. This is way easier but isnt as versatile (like when you want the gun to move around the body for example)
2. Make all the sprites (including the character and the gun) have its own respective position on the map. So for example you can make the character sprite have the script “Go to X, Y when pressed etc”; you want to copy that same script into the gun instead of using the “go to <character>” script which usually cause your problem.
You can check out my newly made shooter game and see how it might help you: https://scratch.mit.edu/projects/390810656/
Hope this helps!
1. I usually just put the gun sprites in the character sprite itself. This is way easier but isnt as versatile (like when you want the gun to move around the body for example)
2. Make all the sprites (including the character and the gun) have its own respective position on the map. So for example you can make the character sprite have the script “Go to X, Y when pressed etc”; you want to copy that same script into the gun instead of using the “go to <character>” script which usually cause your problem.
You can check out my newly made shooter game and see how it might help you: https://scratch.mit.edu/projects/390810656/
Hope this helps!
- zahmbie1
-
Scratcher
1000+ posts
Shooter Game
So, I'm making a shooter game, and I'm coding the gun movement, and I have a little problem.You can also use a broadcast (Not the wait ones!)
I'm using this script:
Got to X: x position of Player, Y: y position of Player
and When I do that script, it sort of works, except when you move, the gun drags behind a little, can someone please help me?
- LordThror
-
Scratcher
100+ posts
Shooter Game
To clarify, whenever the player moves you need to send a broadcast telling the gun that the player has moved. Then, on a receiver block inside the gun sprite put the go-to player block.So, I'm making a shooter game, and I'm coding the gun movement, and I have a little problem.You can also use a broadcast (Not the wait ones!)
I'm using this script:
Got to X: x position of Player, Y: y position of Player
and When I do that script, it sort of works, except when you move, the gun drags behind a little, can someone please help me?
- Discussion Forums
- » Help with Scripts
-
» Shooter Game
