Is it possible to make a rigid body (or something similar) move like a piston along a given axis? I’m trying to make a ledge move back and forth along the x-axis. The ledge has a mass of zero so it doesn’t fall and is supposed to be “floating”. Any ideas?
Physics piston type movement?Software: Away3D 4.x |
||
|
||
Alex Bogartz, Sr. Member
Posted: 17 September 2011 03:09 PM Total Posts: 216 [ # 1 ] The answer lies somewhere in here, perhaps? I haven’t had enough time to play with it. If anyone has a quick explanation I’d be very grateful. |
||
John Brookes, Moderator
Posted: 17 September 2011 04:19 PM Total Posts: 732 [ # 2 ] In that example theres one called slider. It uses AWPGeneric6DofConstraint ps there is a physics section on the forum :p |
||
Alex Bogartz, Sr. Member
Posted: 17 September 2011 10:32 PM Total Posts: 216 [ # 3 ] New physics forum? YES! Thanks, I’ll take a look! |
||
Alex Bogartz, Sr. Member
Posted: 19 September 2011 07:28 PM Total Posts: 216 [ # 4 ] Hi, so there’s one thing about those physics examples that doesn’t seem ideal, and that is that you’re using a timer to decide when to change directions. Part of the problem is that there’s no event fired when a constraint object reaches it’s end point, is there? So I made a new function in AWPGeneric6DofConstraint. It uses AS3 Signals (I know you guys are using that but maybe this idea would be helpful using Events?):
public function testForLimit():void So in my game loop, I do something like this:
if (generic6Dof) When I create the constraint, I add this:
generic6Dof.xLimitReached.add(reverseLedge)
Which simply triggers this:
private function reverseLedge(constraint:AWPGeneric6DofConstraint):void Any thoughts on this approach? Am I missing something built in? Thanks!
|
||
|
||
Alex Bogartz, Sr. Member
Posted: 20 September 2011 03:04 PM Total Posts: 216 [ # 6 ]
You mean triggering an event when the target rotation is met? I’m not sure yet. I was just approaching this like you might in a tweening engine where you can set an onComplete function to fire. I think that would be a really useful addition to the constraints. |
||
John Brookes, Moderator
Posted: 20 September 2011 04:58 PM Total Posts: 732 [ # 7 ] Maybe just check the linear/angular velocity |
||
Alex Bogartz, Sr. Member
Posted: 20 September 2011 05:02 PM Total Posts: 216 [ # 8 ] I just personally prefer the event or signal driven method. Rather than have a list of items to test for, I’d like to just add a listener and wait for each event to trigger. |