cancel
Showing results for 
Search instead for 
Did you mean: 

Object Not Moving - What am I doing wrong?

LadyMo218
Member

0ae724e9878b48299848ac12b85d9444.jpeg

bc13771a4bc641078bc00bad2bba50b9.jpeg

53bf85e5e5b3474b91855f37991f2d4a.jpeg

I have a medkit that gives a player health when he grabs it. What’s supposed to happen is 

1. player grabs medkit :white_heavy_check_mark:

2. medkit provides health :white_heavy_check_mark:

3. medkit is force released :white_heavy_check_mark:

4. medkit moves to new random position after release by player :cross_mark:

What is wrong with my code?

1 REPLY 1

World start populates the list and calls move.

Move will try to move through all the position locations within a single frame and you won't see it. But it also removes the positions from the list. When grab happens, the list is empty. It won't move and even if it didn't remove the positions from the list, it'd randomly move through all the positions for no reason.

What you want to do is keep the positions in the list. just pick a position at random and move it there. If you don't want the same location, just save the current index as a variable, and while the random locations != last location, pick a new random location.

Capture.PNG