How to move an object to the mouse location?

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

1 Like

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.

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?

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!

2 Likes

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?

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?

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?

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

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

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

3 Likes

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!

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

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

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

1 Like

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

1 Like

Thank you for the information.

Hello. I’m trying to implement this and don´t get it to run.

first question: node screenToWorld outputs a vector witch world coords. They are related to… world origin, scene camera local coords,… ?