Rotate object towards a point

How can I rotate an object for example a cube, towars a point.

For exemple I have a cube, on which I drew its eyes on a side, I want that that my cube turns towards another object in such a way that the side with the eyes points directly to the desidered point.

lookAt

If the object’s parent is not scaled or rotated, you could use spatial.lookAt(position, upVector)

@sgold said: If the object's parent is not scaled or rotated, you could use spatial.lookAt(position, upVector)

Or get the total rotation portion of the transform as a Quaternion… and use Quaternion.lookAt. Then it really doesn’t matter.

Really, this question??

The problem with this solution is that the “face” side of the cube is pre-decided automatically, I want to decide which side turn to the point.

@Tanelorn said: The problem with this solution is that the "face" side of the cube is pre-decided automatically, I want to decide which side turn to the point.

So add the cube to a node and rotate it so that the node z-forward is the cube forward.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies

Pay especially close attention to anything that talks about combining two rotations together. Essentially, find the rotation where z+ would be looking at what you want to look at and then combine that with a rotation of 90, 180, -90 degrees or whatever.

By the way, If feel like the others are being a little short with you then understand it’s because it seems from your short question like you haven’t read any of the documentation at all.

I’m reading the JME guide book.

@pspeed said: By the way, If feel like the others are being a little short with you then understand it's because it seems from your short question like you haven't read any of the documentation at all.

Speak for yourself, Pspeed.

@sgold said: Speak for yourself, Pspeed.

Hmmm… I don’t understand. Maybe you have another explanation why everyone but me gave one line answers? Not even with a javadoc link even.

Seems I can’t even get away with being helpful anymore. :confused:

Regarding the docs, it was a guess since he couldn’t figure out how to make his cube’s eyes “look at” something… when the method is actually called “lookAt”. I thought you guys might actually be being facetious.

@pspeed said: Hmmm... I don't understand. Maybe you have another explanation why everyone but me gave one line answers? Not even with a javadoc link even.

Seems I can’t even get away with being helpful anymore. :confused:

I sometimes post brief answers because I’m in a hurry, or because I’m not certain what the OP wants and I hope a quick reply will encourage the OP to provide more detail. I never use them to punish people who have difficulty making sense of the documentation. We’ve all been there!

Because your expertise is precious, I cut you a lot of slack when you are rude on the forums. (Not that I have any power to silence you.) But this time you “crossed a line” and I spoke up.

Paul, when you get frustrated with an OP, you can say so, or you can just ignore the OP and hope s/he goes away. But speculating that the rest of us are fed up with the OP and publicly presenting your speculation as fact is not “helpful”.

@sgold said: I sometimes post brief answers because I'm in a hurry, or because I'm not certain what the OP wants and I hope a quick reply will encourage the OP to provide more detail. I never use them to punish people who have difficulty making sense of the documentation. We've all been there!

Because your expertise is precious, I cut you a lot of slack when you are rude on the forums. (Not that I have any power to silence you.) But this time you “crossed a line” and I spoke up.

Paul, when you get frustrated with an OP, you can say so, or you can just ignore the OP and hope s/he goes away. But speculating that the rest of us are fed up with the OP and publicly presenting your speculation as fact is not “helpful”.

If you read back through the thread… you will see that you are not the only person who responded. You were the nicest of the short responses and that’s as far as I’ll go without being specific. :wink:

Anyway, I’m not even sure how to offer advice to people on how to ask good questions anymore. Even when I try to be nice about it then people think I’m being rude. I read the responses as being “short and rude” and I know better in some cases… but OP is new and might not have known better. Especially with some of the obviously ruder follow-ups. All in context, it seemed a little heavy handed to me… the irony is not lost on me.

But OP essentially asks “How can I make my eyes look at an object” and gets two one line answers, no links, with “lookAt()” basically followed by a response questioning the question itself. Then OP finally follows up with the missing information that would have led us all to believe that he actually had already known about lookAt() and had a deeper question…

So I gave a complete answer with documentation references, things to look for, etc. that will lead OP to the full answer to his question (mostly unasked originally) and try to help him ask a better question next time.

On this forum, I give almost the exact same responses so many times. Sometimes people see them as rude. Sometimes people +1 me, thank me, and get on with their business. When people take the time not to waste our collective time then I take the time to answer in kind. And yes, to those few folks who walk in already with a sense of entitlement then it will depend on my mood.

But really, I’ve gotten flak for posting Java doc links before. So with one-line responses, expect to be joining this ‘rude’ club soon. :wink: We all end up on the dark side eventually.

Heh… what was wrong with lookAt as an answer?

It was the correct answer…

Posting a link to the documentation… or saying RTFM might be rude… but the answer?

It must have been the angry way I typed it… /boggle

@t0neg0d said: Heh... what was wrong with lookAt as an answer?

It was the correct answer…

Posting a link to the documentation… or saying RTFM might be rude… but the answer?

It must have been the angry way I typed it… /boggle

How is a single word less rude than a link to the actual method documentation?

Anyway, it was the whole thread in context that seemed like it could be taken as rude.