I’m making top-down billiard game with Away3D 4.0 and i need to get billiard stick rotated to mouse direction. It should be something like this: http://kirill-poletaev.blogspot.com/2010/07/rotate-object-to-mouse-using-as3.html just in 3D What’s the best way to do that?
Thank you for your answers.
Rotate mesh to mouse direction. (SOLVED)Software: Away3D 4.x |
||
Gugis, Newbie
Posted: 11 July 2012 09:06 AM Total Posts: 6 |
||
Richard Olsson, Administrator
Posted: 11 July 2012 10:41 AM Total Posts: 1192 [ # 1 ] Same as in 2D, but rotate around the Y axis instead of the Z axis (which is the default and sometimes only rotation axis in Flash and other flat screen media.) |
||
Gugis, Newbie
Posted: 11 July 2012 11:05 AM Total Posts: 6 [ # 2 ]
I tried like this:
private function Move(e:MouseEvent):void But it works wrong. Mouse cursor closer to stick - lower rotation angle.
package |
||
Richard Olsson, Administrator
Posted: 11 July 2012 11:15 AM Total Posts: 1192 [ # 3 ] First of all, if you’re doing a top down game you should probably be modifying rotationY, not rotationZ. Second, what is the ball object? Is that a 3D object in your scene? You can’t compare objects’ coordinates in the scene with the coordinates of the mouse on the stage (unless you really know what you’re doing.) Either calculate the position of the ball on the stage (using Camera3D.project()) or the mouse cursors position in 3D space on the plane on which your ball sits (e.g. the table.) You can do the latter by listening for 3D mouse events on that plane instead of using regular mouse events, and using the sceneX, sceneY and sceneZ properties of the event. |
||
Gugis, Newbie
Posted: 11 July 2012 11:24 AM Total Posts: 6 [ # 4 ] Thank you for tips Richard, I almost made it Now I need to move pivot point to the end of stick. It seems movePivot function doesn’t work. Current code:
package
|
||
Richard Olsson, Administrator
Posted: 11 July 2012 01:09 PM Total Posts: 1192 [ # 5 ] There was a bug in movePivot() (and pivotPoint) which was fixed recently in the release branch, meaning that fix will be part of the final 4.0 release very soon. If you want to use movePivot() or the pivotPoint property, please use the release branch from GitHub for now. |