Add Spatial to Rotating Node

I have a scene with an rotating sphere attached to a node called enemyNode. Using ray casting, I mark the surface with a square by attaching to it to enemy node and subtracting the enemyNode position from the contact point. This works perfectly when the enemyNode isn’t rotating, but I don’t know how to compensate for the rotation of the local coordinate system. How do I do that?!

Setting position and rotation of enemyNode to zero and changing back after attaching the square didn’t work :frowning:

I suppose I could give the square it’s own node and rotate around it, but is that the only way?? Ugh, this is killing me :frowning:

I’m not exactly sure what effect you are trying to achieve but it sounds like some combination of:
http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Spatial.html#worldToLocal(com.jme3.math.Vector3f,%20com.jme3.math.Vector3f)

and/or:
http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/Spatial.html#localToWorld(com.jme3.math.Vector3f,%20com.jme3.math.Vector3f)

…is in order.

Probably the first one.

1 Like

I love you :cry: