I am trying to build a spoon egg game and I am creating both egg and spoon shapes using AWPConvexHullShape. The problem is the egg is appearing a little bit above from the spoon and I cant figure it why! The code I am using is
scene.addChild(spoonModel);
var spoonShape:AWPConvexHullShape = new AWPConvexHullShape(spoonModel.geometry);
spoonBody = new AWPRigidBody(spoonShape,spoonModel,0);
spoonBody.friction = 4;
spoonBody.position = new Vector3D(0,0,-150);
spoonBody.rotationY = -90;
physicsWorld.addRigidBody(spoonBody);
scene.addChild(eggModel);
var eggShape:AWPConvexHullShape = new AWPConvexHullShape(eggModel.geometry);
eggBody = new AWPRigidBody(eggShape,eggModel,1);
eggBody.position = new Vector3D(0,100,10);
eggBody.mass = 10;
eggBody.rotationY = -90;
eggBody.friction = 4;
physicsWorld.addRigidBody(eggBody);
I don’t have any clue about what was happening because I cant see the debugdraw also. I have searched for any tutorial about debugdraw and I found none.
It would be very grateful for me If I got through this.
]]>Error #1520: Mutex cannot be initialized.
If I comment out that one declaration, it’s fine. And If I publish as a non-mobile AIR app, it works fine. Any thoughts? Has anyone successfully used AwayPhysics on iOS (in all my searches for AwayPhysics errors, I’ve only seen one post with a Mutex error and the solve was using Air 3.4 - not something I’d like to do). Any thoughts?
]]>I am trying to build a spoon egg game and I am creating both egg and spoon shapes using AWPConvexHullShape. The problem is the egg is appearing a little bit above from the spoon and I cant figure it why! The code I am using is
scene.addChild(spoonModel);
var spoonShape:AWPConvexHullShape = new AWPConvexHullShape(spoonModel.geometry);
spoonBody = new AWPRigidBody(spoonShape,spoonModel,0);
spoonBody.friction = 4;
spoonBody.position = new Vector3D(0,0,-150);
spoonBody.rotationY = -90;
physicsWorld.addRigidBody(spoonBody);
scene.addChild(eggModel);
var eggShape:AWPConvexHullShape = new AWPConvexHullShape(eggModel.geometry);
eggBody = new AWPRigidBody(eggShape,eggModel,1);
eggBody.position = new Vector3D(0,100,10);
eggBody.mass = 10;
eggBody.rotationY = -90;
eggBody.friction = 4;
physicsWorld.addRigidBody(eggBody);
I don’t have any clue about what was happening because I cant see the debugdraw also. I have searched for any tutorial about debugdraw and I found none.
It would be very grateful for me If I got through this.
]]>Is it possible to use AwayPhysics on mobile devices? Or should I try other engine? Should I adjust the apps for their operating systems?
Thanks in advance ![]()
if (keyForward)
{
if (walkDirection.length == 0)
{
_animationController.play("walk", _stateTransition);
_animationController.playbackSpeed = 1;
}
walkDirection = character.ghostObject.front;
walkDirection.scaleBy(walkSpeed);
character.setWalkDirection(walkDirection);
}
]]>
For a project I need to work the MouseJoint in real 3D, not only in a look-alike-3D as in the former example. My idea was to create a “MouseObject” at the position where the user clicks at the draggable object. Then create a AWPPoint2PointConstraint with the MouseObject and the draggable box as the two RigidBodies. Then create a Drag3D-Object for the MouseObject and update that in the render-loop. Unfortunately something must be really wrong in my code, because the result looks quite weird.
So please, is there anybody out there to show me how it works with AwayPhysics?
Here’s what I got so far:
//create a draggable box
var size:int = 400;
var mass:int = 10;
var mat:ColorMaterial = new ColorMaterial(0xfc6a11);
mat.lightPicker = _lightPicker;
_boxMesh = new Mesh(new CubeGeometry(size,size,size),mat);
var shape:AWPBoxShape = new AWPBoxShape(size,size,size);
_boxBody = new AWPRigidBody(shape, _boxMesh, mass);
_boxBody.position = new Vector3D(0,1000,0);
_view.scene.addChild(_boxMesh);
_world.addRigidBody(_boxBody);
_boxMesh.mouseEnabled = true;
_boxMesh.addEventListener(MouseEvent3D.MOUSE_DOWN, startDragging);
//here are the two mouse-handlers:
private function startDragging(e:MouseEvent3D):void
{
_boxMesh.removeEventListener(MouseEvent3D.MOUSE_DOWN, startDragging);
_view.stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
var mouseDownPos:Vector3D = new Vector3D(e.object.x, e.object.y, e.object.z);
// add mouse object
_mouseBody.position = mouseDownPos;
_view.scene.addChild(_mouseMesh);
_world.addRigidBody(_mouseBody);
// create the mouse joint
_mouseJoint = new AWPPoint2PointConstraint(_mouseBody, mouseDownPos, _boxBody, new Vector3D());
_world.addConstraint(_mouseJoint, true);
// enable dragging
_drag3D = new Drag3D(_view, ObjectContainer3D(_mouseMesh), "xy");
_drag3D.offsetCenter = false;
_dragging = true;
}
private function stopDragging(e:MouseEvent):void
{
_dragging = false;
_boxMesh.addEventListener(MouseEvent3D.MOUSE_DOWN, startDragging);
_view.stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);
// remove the mouse joint
_world.removeConstraint(_mouseJoint);
_mouseJoint = null;
// remove the mouse object
_view.scene.removeChild(_mouseMesh);
_world.removeRigidBody(_mouseBody);
}
// and my render loop:
private function loop(e:Event) : void
{
_world.step(timeStep);
_debugDraw.debugDrawWorld();
if(_dragging) {
_drag3D.updateDrag();
_mouseBody.position = _mouseMesh.position;
}
_view.render();
}
Whole AS-File is attached below.
Any help is highly appreciated.
Thanks,
Markus
Some questions ...
is it possible?
is it recommended?
use collisionshapes or rigidbodies?
alternatives?
would be awesome if somebody can lead me into the right direction ^^
thx!
]]>The only way I´ve discovered until now is changing the rigidBody´s scale, but in some situations, I´de like to change the shape, but
rigidBody.shape = anotherShape
is not pssible (ther´s no such setter function)
Thanks.
]]>Tks in advance
]]>