Make object follow mouse

Good day! I’m trying to make a work for my courses and this is my task.
I need an object to follow my mouse. But I simply can’t figure out how to do that. I really don’t have much time for now to figure it out. I understand the logic and how to do that but I just can’t do that on jMonkey. It’s not a very big task so I would really appretiate if anyone could just help me with the code and the idea of doing it. I really need help much. Thank you

Update the location of a spatial on the GUI node to the cursors current position.

someSpatial.setPosition(inputManager.getCursorPosition());

put something like that on your update loop and should be what you need.

@BigBob said: Update the location of a spatial on the GUI node to the cursors current position.

someSpatial.setPosition(inputManager.getCursorPosition());

put something like that on your update loop and should be what you need.

Thank you for your answer. But I really can’t figure it out still. I don’t have anything that has a setPosition method.

Hi there,

I can see you’re new and a great place to seek help with this stuff is the #jmonkeyengine irc on freenode.net

But what you’re looking for is to set the position using something like, setLocalTranslation() method, but it depends on what type of “object” you’re using.

Keep in mind when you use the word “object” it could be literally anything following your mouse. I just assume it’s a spatial or perhaps a GUI element.

Also, if you are new to JME and don’t feel like asking 100 simple questions on IRC… the tutorials will cover most of them if you take some time to go through them.

@pspeed said: Also, if you are new to JME and don't feel like asking 100 simple questions on IRC... the tutorials will cover most of them if you take some time to go through them.
Thank you for the advice, but unluckily I don't have time at all. It's one of many tasks for my classes and the exam is tomorrow. So that's why I needed the code solution. But in time I will take a look at tutorials :)
@BigBob said: Hi there,

I can see you’re new and a great place to seek help with this stuff is the #jmonkeyengine irc on freenode.net

But what you’re looking for is to set the position using something like, setLocalTranslation() method, but it depends on what type of “object” you’re using.

Keep in mind when you use the word “object” it could be literally anything following your mouse. I just assume it’s a spatial or perhaps a GUI element.

Thanks for the IRC. I was talking about simple boxes, I just need a simple program that will do so: One box is following mouse, the second is following the first (facing it). That is all. Must be simple, but I’m not used to jMonkey (worked with XNA earlier and it’s slightly different)