Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Move towards mouse with no move(steps) block
- 0znzw
-
Scratcher
84 posts
Move towards mouse with no move(steps) block
i want to be able to move towards the mouse on mouse down but have camera shake i was thinking something like this
define movetowardsmouse(move)but that did not work :\
point towards [mouse v]
change x by ((0.9) * ((sin(mouse x))+((shake) * (move)))
change y by ((0.9) * ((cos(mouse y))+((shake) * (move))))
Last edited by 0znzw (Feb. 22, 2022 22:51:10)
- LavenderLemonSquare
-
Scratcher
85 posts
Move towards mouse with no move(steps) block
try :
when green flag clicked
forever
go to [mouse pointer v]
end
- belangermediaa
-
Scratcher
100+ posts
Move towards mouse with no move(steps) block
try :i don't think you read the request, they are asking for it to move towards the mouse on mouse downwhen green flag clicked
forever
go to [mouse pointer v]
end
- The_Imaginarium
-
Scratcher
1000+ posts
Move towards mouse with no move(steps) block
You should have a universal variable that controls camera shake.
You could have something like:
I encourage you play around with the numbers to get the desired result
You could have something like:
when green flag clicked
set [ShakeX v] to [5] // how much it shakes in the x direction
set [ShakeY v] to [5] // how much it shakes in the y direction
set [Speed v] to [10] // how fast object moves
forever
set [ShakeX v] to (((pick random (0.95) to (1.05)) * (ShakeX)) * (-1))
set [ShakeY v] to (((pick random (0.95) to (1.05)) * (ShakeY)) * (-1))
end
//Then for the movement:
// This script just takes the normalized vector from object to the mouse
when green flag clicked
forever
if <(distance to [mouse-pointer v]) > (Speed)> then
change x by ((((mouse x) - (x position)) / ([distance v] of [mouse-pointer v])) * (Speed))
change y by ((((mouse y) - (y position)) / ([distance v] of [mouse-pointer v])) * (Speed))
end
change x by (ShakeX)
change y by (ShakeY)
end
I encourage you play around with the numbers to get the desired result
- The_Imaginarium
-
Scratcher
1000+ posts
Move towards mouse with no move(steps) block
I made a demo real quick: https://scratch.mit.edu/projects/648982538/
- Discussion Forums
- » Help with Scripts
-
» Move towards mouse with no move(steps) block