Something going slowly to another object

helpwithcode

#1

I'm making a game (stop reading if you don't want spoilers) where you needs to swipe stuff away from a pixel to keep the pixel from eating it. But, I want the things going towards the pixel to, well, go step by step moving to the pixel's position. How is this possible? Thank you for reading and please explain. Here is a screenshot if you don't understand:


#2

Use change x, y for moving it closer but have the x and y number low.


#3

use a set speed and do this
change whatever your using to move it and say ____ 2 wait 100 ml inside a repeat ___


#4

if you don't want to use trig:

forever
if (pixel X)>(food X)
change (food X) by -1
else
change (food X) by 1
if (pixel y)>(food y)
change (food y) by -1
else
change (food Y) by 1

if you do want to use trig:

insert trig here


#5

Yeah you might have to use set speed like @SnowGirl_Studios said.


#6

@justanerd screenshots please. I am better that way.


#7

Uploading...
can you pls give credit to me in the game :grinning:
I recently realized that 84% of hopscotches don't even know who I am :confused:


#8


#9

@justanerd thank you. You are very helpful. I will try this.


#10

@justanerd I WORKS!!! You are awesome! One question: do you increase the number to make it go faster? (Like instead 2 and -2, 3 and -3?) would that still work?


#11

Yes it would still work, it would still work because it is moving at a faster pace, the amount of times it moves.


#12

Second question:


(If you are wondering, I added an extra Check Once If to make it with the game, but for now, the value is always 0 so it is like the Check Once If is not there.)


#13

The rules on the side that you circled is that you have to invert the change x/y' block to be positive numbers.


#14

@Phase_Studios do you mean like this?


Because when it's like that it goes a different way but still the wrong way....


#15

yes, I changed from 1 to 2 to make it faster because 1 was super slow, but yeah, higher numbers=faster, but don't go past 10 w/out setting speed to 99999999999... otherwise it will be chunky


#16

You are right, it gets weird looking, I am making a game that has this kind of stuff with this.


#17

and of course, if you're in 276th grade math you can use trig to make it move in the exact right direction and it won't look quite as bad, but I'm in 8th grade... so I don't know anything about sine and cosine and the hypotenuse or all those other big trigonometry words, I can work with algebra though :grinning: which sadly does nothing in this case, but I am trying my best to self teach myself trigonometry to make a raycaster engine... but it's not working to well


#18

I am teaching myself trigonometry, it is hard. I am in 6th grade I think we learn this in high school or something.


#19

I still need an answer because @Phase_Studios's answer didn't work :cry:


#20

I'm in 8th grade too. (20202020)