I’m a math teacher and I want to do a game for my students using blender’s GE. The idea is to do a “clone” of Portal but instead of using portals, they will have to solve mathematicals problems to advance in the game. Basicaly they will have to find a cube with the appropriate value to put on the button.
Anyway, I want to do a gravity gun to take the cubes. The various examples I’ve found do not really achieve what I want, so I’m doing it myself.
I have 2 problems.
First, to avoid the cubes to hit the player when they are attracted, I want to calculate the next position the attracted cube will have and if it will hit the player, I put it in the position where it is held. The problem is that the formula I’m using does not seems to work.
Basically, I calculate the force for each coordinate. Then I calculate the displacement from the previous frame (I use variables to keep the previous position of the cube). Finally, I use this formula for each coordinate:
futur position = actual position + previous displacement + force/(mass of the cube * 60)
The 60 comes from the fact that there is 60 frames per second.
But the result is not correct.
The other problem is that, once the cube is held, I use “setPosition” to put it in a particular point. But, I don’t understand why, it is slowly going down, even so I use setPosition every frame.
If you have any ideas…
p.s.: My file is kind of a mess and the comments are in french, but at least you can test it.
FPS_attraction_gun_new_grav2.blend (709 KB)