[Away3d 4.0 + JigLib] Acurrate Moving an Object instead of forcing it to roll

Software: Away3D 4.x

Indyaner, Newbie
Posted: 03 January 2014 11:44 PM   Total Posts: 5

Hello

I’m currently play myself into away3D and jiglib. Sadly, there doesn’t seem to be a huge amount of eye-opening Tutorials for jiglibflash, thats why I’m stuck at the level of reading the classes and their parameters to figure out whats going on and how to solve problems.

I’m a bit stuck at the basic concept of moving objects. I’m using the code from someone who made a great simple setup of how a ball is rolling thru a field of boxes. I’ve altered the code to generate random positioned boxes that are not movable.

But I cant figure out how I can move the Sphere to exact coordinates without losing the connection to the rigidModel-physics. I tried .moveTo() and calculated the values of two Vector3D, but this disturbs the collision detection on the cubes. I’ve tried different Methodes like addWorldForce, addBodyForce, applyWorldImpulse, etc; basicly all the methodes you can read up here: http://www.jiglibflash.com/docs/jiglib/physics/RigidBody.html
I even tried setActive, as someone suggested in a post. No chance.

So i turn to you away3D Forum. How can I move an object without ease and friction to a precise location without lossing maintaining the colission-physics.

Best wishes
Indyaner

 

File Attachments
Test.as  (File Size: 10KB - Downloads: 325)
   

John Brookes, Moderator
Posted: 04 January 2014 11:33 AM   Total Posts: 732   [ # 1 ]

Long time since played with Jiglib so may be wrong.
If you dont want to use forces to move a rigidbody set the linear velocity.
eg
rigidBody.setLineVelocity(new Vector3D(5, 0, 0));

moveTo is for when your setting up position or teleporting. It doesnt care that you may put in inside a wall or in the floor.

   

Indyaner, Newbie
Posted: 04 January 2014 03:03 PM   Total Posts: 5   [ # 2 ]

Thanks for your input.

I’ve tried it with mixed feelings. It does indeed works, and the cube is moving more precise, but its still not a real (read:rounded) number. I hoped to get a step able behavior like 101,102,103, etc.

I’ve used the following line of code for movement:

ball.setLineVelocity(new Vector3D(400)); 

I’ve echoed the value in the beginning and after the moving:

trace(ball.currentState.position); 

What I got was this:

Vector3D(-10050, -200)
Vector3D(-104.113193443318649.99332775838788, -204.14302358988462)
Vector3D(-104.113193443318649.99332775838788, -204.14302358988462)
Vector3D(-103.763951361165659.994223282428601, -204.14262733960916)
Vector3D(-102.379040219647159.992564902415117, -204.14562442785103

So it does move, and stops way further then by adding force, but its still very inaccurate. I’ve changed the values for friction and restitution for the ground to zero, but it looks like I still get floating position data.

Can I ask you why you haven’t played with jiglib in quite a time? Is there a better physic/collision engine out there I dont know about? Because the google search results for “jiglib [method]” are sometimes really scary (like 4-5 posts).

Best Regards
Indyaner

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X