Discuss Scratch

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:

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!

(pronouns are she/her). Advanced Alpha Game Studios Manager; website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













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
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?

qwertycodechamp90411 wrote:

Also guns will break the scratch tos i think
How so?

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)


New game! (link)
Have a good day/night!


\(-_-) ::#00AAAA //This is crypto. He protects my signature from the evil kumquats!
Programming is a very powerful skill. As are critical thinking and hard work.
- SpyCoderX


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?

SpyCoderX wrote:

qwertycodechamp90411 wrote:

Also guns will break the scratch tos i think
How so?

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
Yes many. In fact I have with cartoony guns and blood and it's been up since december last year.

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)


(pronouns are she/her). Advanced Alpha Game Studios Manager; website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













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?

SpyCoderX wrote:

qwertycodechamp90411 wrote:

Also guns will break the scratch tos i think
How so?

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?

y-no-available-user wrote:

SpyCoderX wrote:

qwertycodechamp90411 wrote:

Also guns will break the scratch tos i think
How so?

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?
Yep

(pronouns are she/her). Advanced Alpha Game Studios Manager; website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













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 clicked
forever
go to x: (([X] of [Sprite1]) + (30)) y: ([Y] of [Sprite1])
end


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?

Apollo11LeoTutorials wrote:

when green flag clicked
forever
go to x: (([X] of [Sprite1]) + (30)) y: ([Y] of [Sprite1])
end


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)

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?

MrKingofScratch wrote:

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)

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)


(pronouns are she/her). Advanced Alpha Game Studios Manager; website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













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?

MineTurte wrote:

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?

y-no-available-user wrote:

MineTurte wrote:

delete this

what
I wrote something incorrect and only realized after posting lol.

(pronouns are she/her). Advanced Alpha Game Studios Manager; website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













Powered by DjangoBB