How to move an object to the mouse location?


#1

I am trying to have an object (sphere) move to the mouses location. I have looked at the Wobbley Rick Sanchez showcase and have made a node system which I thought would work, image below. When running the game, the object can be seen but then as soon as I move the mouse over the top, it disappears. I will attach the file via dropbox, really need help on this one.

Thanks

File


#2

you need to plug a “Screen to world space” node between the “Mouse Cords” and “Separate XYZ” node. You will probably need to move the resulting position a bit with the “Vector Math” node, since at least for me it is usually off by about -30 and +70.


#3

Thats great, it is now moving but its a bit off which is I think what you mean by the -30 and +70. Is that -30 for the x and +70 for the y?


#4

For me, this setup provided the best results. Don’t know why I used “Set Transform” instead of “Set location”, both should work the same in this case. Try out what works for you best!


#5

That’s so much better! Still ever so slightly off but I can mess with that. Only issue is that mine doesn’t go up and down, only left and right?


#6

In your first picture you used the "Mouse Cords"s Y and Z axis, but it only outputs X and Y. Maybe it is that?


#7

I am now using the correct system based on your picture but still it is not working. I assume the mouse coordinates outputs the x and y but does the object move on the axis in reference to the blender axis so z for instance is straight up so I would want y to go into z?


#8

if you want the object to move up, not forwards when you move you mouse upwards, yes.


#9

Would it be possible for you to have a look at my blend file? I just dont know what im doing wrong


#10

Looked at your .blend and I now think I got wrong what you were after. This setup moves the ball on Z and Y axis in front of the Player, fortunately it is way simpler than the previous one.


I thought your camera was on one axis at least on 0 rotation. Sorry for that and the late reply


#11

That is great thank you so much! Last question I promise, is there any way to decide how fast it moves, ie: slow it down a bit when moving?

Thanks again, so helpful!


#12

just modify the value in the “Vector Math”-> multiply node, this would be something like a mouse sensitivity value.


#13

tried both of your examples,Simonrazer,but none of it works,checked every node triple
is here any other playarounds?
and is this not bug? i mean what coords off by some distance from real coordinates is not something you expect


#14

This method works better, the other one maybe depends on the camera position as well. This one doesn’t.


#16

The pick object node is pretty simpler.
There’s a picking example currently in armory examples.


#17

Thank you for the information.