Making a box to catch coockies

Software: Away3D 4.x

Harilal K M, Newbie
Posted: 04 June 2014 05:43 AM   Total Posts: 16

hi,

Am making a game to catch coocckies which is falling from the sky.

I was able to make Box class which extends ObjectContaner3D
here is my code : http://pastebin.com/yRHrg846

My doubt is how to add body to this Box. Can i create the body inside the Box class and add to the AWPDynamicsWorld? or i need to create it in main class? Am confused.. And also i found AWPCompoundShape class. Whether i need to use this ?Please Help me..

   

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

You add Mesh/ObjectContainer3D to the rigibody.
You would create a compoundShape by adding boxShapes that would be the walls of your container.

Cant remember the name of the demo file in the physics examples. Its the one with some chairs made by using compound shapes. Have a look at that on how to build.

   

Harilal K M, Newbie
Posted: 05 June 2014 05:51 AM   Total Posts: 16   [ # 2 ]

hi.

Sorry .. i just didn’t got the idea. I already created a box extend ObjectContainer3D . But still no idea how to add to rigidbody. Is there any way to get any docs ?
I checked the example which is CompoundShapeTest.as . But i need to create a seperate class for the box. In that case , Where we need to add the rigidbody? inside the class? if so the cordinates is based on the ObjectContainer3D or the stage? That’s where am confused..

   

Harilal K M, Newbie
Posted: 06 June 2014 05:50 AM   Total Posts: 16   [ # 3 ]

@johnBrookes : I did it just like you said it. And it’s working. With only one problem. When i catch the ball and when i move the basket fast it go through the walls of the box. Do you have any idea?

   

Harilal K M, Newbie
Posted: 11 June 2014 01:39 PM   Total Posts: 16   [ # 4 ]

I Just created a box and am able to catch the ball. But the ball goes through the walls when i move fast the box. And also how can i know the ball is inside the box?

   

Harilal K M, Newbie
Posted: 18 June 2014 06:40 AM   Total Posts: 16   [ # 5 ]

hi,
Anyone can help me? Am waiting for support.

   

Jillinger, Newbie
Posted: 30 June 2014 10:32 PM   Total Posts: 29   [ # 6 ]

Here.

   

Harilal K M, Newbie
Posted: 01 July 2014 06:30 AM   Total Posts: 16   [ # 7 ]

@Jillinger , I couldn’t figure out difference in your code and the example one?
Could you pls specify what actually you have done?

   

Jillinger, Newbie
Posted: 01 July 2014 07:01 PM   Total Posts: 29   [ # 8 ]

I was only able to send you this information because I have Diff Daff. It compares files, and shows you the difference. You can download it for free.

BasicTest.as

private function onMouseUp(MouseEvent) : void {
var pos Vector3D _view.camera.position;
var 
mpos [color=green]Vector3D = new Vector3D(pos.x,pos.y,pos.z);[/color]

private function onMouseUp(event MouseEvent3D) : void {
var pos Vector3D _view.camera.position;
var 
mpos Vector3D = new [color=red]Vector3D(event.localPosition.xevent.localPosition.yevent.localPosition.z);[/color] 

I got an error here.

 

CharacterDemo.as

import away3d.animators.states.[color=green]ISkeletonAnimationState;[/color]
import away3d
.animators.transitions.[color=green]CrossfadeTransitionState;[/color]

 
//*NOTE the difference -  import away3d.animators.transitions.[color=red]CrossfadeStateTransition;[/color]

//private var _animationController : SkeletonAnimator;
//private var _stateTransition:CrossfadeTransitionState;

//_stateTransition = new CrossfadeTransitionState(_animationController, null);
//_animationController = new SkeletonAnimator(_animationSet,_skeleton);
//_animationController.updatePosition = false;
//_characterMesh.animator = _animationController;
 
private function onAnimationComplete(event AssetEvent) : void 
{
 
if (event.asset.assetType == AssetType.ANIMATION_STATE
 
{
  
var animationState:ISkeletonAnimationState event.asset as [color=green]ISkeletonAnimationState[/color];
  
//_animationSet.addState(animationState.assetNamespace, animationState);

   //*NOTE -   var animationState:SkeletonAnimationState = event.asset as [color=red]SkeletonAnimationState;[/color]
    
_animationSet.addState(animationState.assetNamespaceanimationState);
   
  if (
animationState == "idle")
  
{
   
//_animationController.playbackSpeed = 1;
   //_animationController.play("idle");
  
}
 }
}

//_animationController.playbackSpeed = 1;
//_animationController.play("idle");

//_animationController.playbackSpeed = 1;
//_animationController.play("idle");

//_animationController.play("walk");
//_animationController.playbackSpeed = 1;

//_animationController.play("walk");
//_animationController.playbackSpeed = -1; 

I took out all the animation transitions, because the returned errors. So the character does not animate.


VehicleTerrainTest.as
The terrain folder was missing

 

   

Jillinger, Newbie
Posted: 01 July 2014 07:05 PM   Total Posts: 29   [ # 9 ]

Ignore that post. It’s confusing. I pressed the preview and it was sent - bug on the forum.

I was only able to send you this information because I have Diff Daff. It compares files, and shows you the difference. You can download it for free.

BasicTest.as
private function onMouseUp(e : MouseEvent) : void {
var pos : Vector3D = _view.camera.position;
var mpos : Vector3D = new Vector3D(pos.x,pos.y,pos.z);

private function onMouseUp(event : MouseEvent3D) : void {
var pos : Vector3D = _view.camera.position;
var mpos : Vector3D = new Vector3D(event.localPosition.x, event.localPosition.y, event.localPosition.z);

I got an error here.

CharacterDemo.as
import away3d.animators.states.ISkeletonAnimationState;
import away3d.animators.transitions.CrossfadeTransitionState;

//*NOTE the difference -  import away3d.animators.transitions.CrossfadeStateTransition;

//private var _animationController : SkeletonAnimator;
//private var _stateTransition:CrossfadeTransitionState;

//_stateTransition = new CrossfadeTransitionState(_animationController, null);
//_animationController = new SkeletonAnimator(_animationSet,_skeleton);
//_animationController.updatePosition = false;
//_characterMesh.animator = _animationController;

private function onAnimationComplete(event : AssetEvent) : void
{
if (event.asset.assetType == AssetType.ANIMATION_STATE)
{
  var animationState:ISkeletonAnimationState = event.asset as ISkeletonAnimationState;
  //_animationSet.addState(animationState.assetNamespace, animationState);

  //*NOTE -  var animationState:SkeletonAnimationState = event.asset as SkeletonAnimationState;
  _animationSet.addState(animationState.assetNamespace, animationState);
 
  if (animationState == “idle”)
  {
  //_animationController.playbackSpeed = 1;
  //_animationController.play(“idle”);
  }
}
}

//_animationController.playbackSpeed = 1;
//_animationController.play(“idle”);

//_animationController.playbackSpeed = 1;
//_animationController.play(“idle”);

//_animationController.play(“walk”);
//_animationController.playbackSpeed = 1;

//_animationController.play(“walk”);
//_animationController.playbackSpeed = -1;

I took out all the animation transitions, because the returned errors. So the character does not animate.


VehicleTerrainTest.as
The terrain folder was missing

 

   

Harilal K M, Newbie
Posted: 02 July 2014 06:31 AM   Total Posts: 16   [ # 10 ]

actually my problem is different. I think it’s related to CCD. One my object go through the walls of the box. I can’t figure out what went wrong.

   

Jillinger, Newbie
Posted: 02 July 2014 12:09 PM   Total Posts: 29   [ # 11 ]

I don’t know. I did have to remove CCD from my rigid body spheres, because they were stopping abruptly, and not rolling naturally. I believe it has to do with the mass of the object. My guess is that once CCD is enabled, one then has to change the mass of the object, so that the object being hit is not weaker than the object being thrown. Try playing around with your object’s mass. You can also read the info on the Panda3d link, and see if you get any ideas. Or, better yet, examine the code in ‘ConstraintTest.as’ example. I noticed that it seems to use soft body and hard body objects being hit by a projectile.
I hope you get you problem fixed.

   

Jillinger, Newbie
Posted: 03 July 2014 12:50 AM   Total Posts: 29   [ # 12 ]

I just discovered that the ‘CompoundShapeTest.as’ does exactly what you want. I didn’t realize that you can shoot balls at the chairs. Dd you notice?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X