Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
- y-no-available-user
- Scratcher
5 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
Hi, I've been trying to figure out how to make a sprite, and in this case a gun to follow the player on their right when the player points towards the mouse pointer. I can't quite figure that out, so I would appreciate some help. (the game im working on: https://scratch.mit.edu/projects/964784062/)
Last edited by y-no-available-user (March 28, 2024 01:01:21)
- MineTurte
- Scratcher
500+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
Well for your first problem:
And for your second problem you can use something I already made: https://scratch.mit.edu/projects/897686744/
Hope this helps!
when green flag clicked
forever
go to [ sprite you want to go to]
change x by (30)
end
And for your second problem you can use something I already made: https://scratch.mit.edu/projects/897686744/
Hope this helps!
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- qwertycodechamp90411
- Scratcher
100+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
Also guns will break the scratch tos i think
Useful Links: Text Generator ——— Encoders/Decoders (Normal, Case Sensitive) ——— New Math Blocks ——— Comment what next on my profile!
Wait, we’re at 900 million projects? So close to 1 billion projects uploaded to the server!
<((x) ^ ((1) / (y))::operators) = ((y) √ (x)::operators)> // is false if x < 0???Hi! I'm qwertycodechamp90411. I'm most active on the suggestions forum and the help with scripts forum, because I like to help other people and improve scratch! I like to think I'm good at scratch, but there's a lot I don't know/understand (how on earth do scrolling platformers work lol). As a general rule of thumb, I should have the answer if it's math related, because I'm a very stereotypical nerd when it comes to math.
- SpyCoderX
- Scratcher
1000+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
How so? Also guns will break the scratch tos i think
Aren’t there many projects with weaponry?
Also, smooth movement:
when green flag clicked
set [xvel v] to (0)
set [yvel v] to (0)
forever
set [xvel v] to (((xvel)+(<key (d v) pressed?>-<key (a v) pressed?>))*(0.7))
set [yvel v] to (((yvel)+(<key (w v) pressed?>-<key (s v) pressed?>))*(0.7))
change x by (xvel)
change y by (yvel)
end
Last edited by SpyCoderX (March 21, 2024 03:22:04)
^ Below this line is my signature ^
New to the forums? Click here!
<Skilled Coder | Forum Helper (about) | Scratch Lab>
What we need may not be what we want.
Banner by Scratchboxes
- MineTurte
- Scratcher
500+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
Yes many. In fact I have with cartoony guns and blood and it's been up since december last year.How so? Also guns will break the scratch tos i think
Aren’t there many projects with weaponry?
Also, smooth movement:when green flag clicked
set [xvel v] to (0)
set [yvel v] to (0)
forever
set [xvel v] to (((xvel)+(<key (d v) pressed?>-<key (a v) pressed?>))*(0.7))
set [yvel v] to (((yvel)+(<key (w v) pressed?>-<key (s v) pressed?>))*(0.7))
change x by (xvel)
change y by (yvel)
end
https://scratch.mit.edu/projects/942005946/
and even one that has really high realistic blood but it has a security code that I deleted the visuals of in the JSON file so you physically can't access it without the code, in which no one knows but me. (The entire code for the security code, meaning you can't just edit the game and bypass it. It's stuck.
Last edited by MineTurte (March 21, 2024 12:51:01)
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- y-no-available-user
- Scratcher
5 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
How so? Also guns will break the scratch tos i think
Aren’t there many projects with weaponry?
Also, smooth movement:when green flag clicked
set [xvel v] to (0)
set [yvel v] to (0)
forever
set [xvel v] to (((xvel)+(<key (d v) pressed?>-<key (a v) pressed?>))*(0.7))
set [yvel v] to (((yvel)+(<key (w v) pressed?>-<key (s v) pressed?>))*(0.7))
change x by (xvel)
change y by (yvel)
end
Just saying, the player always points towards the mouse pointer, and to make the gun point towards the mouse pointer I just have to add the point towards block, am I correct?
- MineTurte
- Scratcher
500+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
YepHow so? Also guns will break the scratch tos i think
Aren’t there many projects with weaponry?
Also, smooth movement:when green flag clicked
set [xvel v] to (0)
set [yvel v] to (0)
forever
set [xvel v] to (((xvel)+(<key (d v) pressed?>-<key (a v) pressed?>))*(0.7))
set [yvel v] to (((yvel)+(<key (w v) pressed?>-<key (s v) pressed?>))*(0.7))
change x by (xvel)
change y by (yvel)
end
Just saying, the player always points towards the mouse pointer, and to make the gun point towards the mouse pointer I just have to add the point towards block, am I correct?
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- Apollo11LeoTutorials
- Scratcher
3 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
when green flag clickedend
forever
go to x: (([X] of [Sprite1]) + (30)) y: ([Y] of [Sprite1])
Hope this works for you!
Last edited by Apollo11LeoTutorials (March 25, 2024 13:53:51)
- y-no-available-user
- Scratcher
5 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
when green flag clickedend
forever
go to x: (([X] of [Sprite1]) + (30)) y: ([Y] of [Sprite1])
Hope this works for you!
Does it follow the mouse pointer??? (the player points towards the mouse pointer)
- MrKingofScratch
- Scratcher
100+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
You can use this script in the post above this in the blaster sprite (g*ns are against the community guidelines)
(code removed because someone beat me to it while i was writing it XD)
(code removed because someone beat me to it while i was writing it XD)
Last edited by MrKingofScratch (March 27, 2024 06:00:38)
Last edited by kaj (Tomorrow 00:00:00)
█▀▄▀█ █▀█ █▄▀ █ █▄░█ █▀▀ █▀█ █▀▀ █▀ █▀▀ █▀█ ▄▀█ ▀█▀ █▀▀ █░█
█░▀░█ █▀▄ █░█ █ █░▀█ █▄█ █▄█ █▀░ ▄█ █▄▄ █▀▄ █▀█ ░█░ █▄▄ █▀█
100th post!
- y-no-available-user
- Scratcher
5 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
blaster sprite (g*ns are against the community guidelines)You can use this script in the post above this in the
(code removed because someone beat me to it while i was writing it XD)
Do you mind reposting it? I think the person who posted it removed their post bc It ain't there
- MineTurte
- Scratcher
500+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
delete this
Last edited by MineTurte (March 28, 2024 12:47:42)
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- y-no-available-user
- Scratcher
5 posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
delete this
what
- MineTurte
- Scratcher
500+ posts
How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?
I wrote something incorrect and only realized after posting lol.delete this
what
she/her
Front-end web developer and software programmer
Javascript, HTML5, CSS, Python3, & Lua.
Signature color gradients here
cool LiDAR game!
AAGS Manager
- Discussion Forums
- » Help with Scripts
- » How do you make it so that a sprite is always on the right/left of another sprite while pointing towards the mouse pointer?