Correct Way to set up Collisions Please

Software: Away3D 4.x

Jillinger, Newbie
Posted: 23 June 2014 05:20 PM   Total Posts: 29

I’m looking at some examples to learn how to do collisions.
I followed a video as well as the code examples which all use:

private var physicsWorld:AWPDynamicsWorld;

public function..... 
{
   physicsWorld 
= new AWPDynamicsWorld.getInstance();

When I tried the same thing, I get an error:

col: 40 Error: Method cannot be used as a constructor.
  physicsWorld = new AWPDynamicsWorld.getInstance();

What does that mean, and how can I fix it?

   

Jillinger, Newbie
Posted: 27 June 2014 04:52 PM   Total Posts: 29   [ # 1 ]

I say this with all seriousness and honesty. I’ve been on many forums before, and received an answer to a post within a day. This forum… I see many posts from newbies like my self, with over 200 views and not a single reply. No joke - This forum should have the title: Community & Support for Only a Select Fewmad.

   

Jillinger, Newbie
Posted: 27 June 2014 04:53 PM   Total Posts: 29   [ # 2 ]

I say this with all seriousness and honesty. I’ve been on many forums before, and received an answer to a post within a day. This forum… I see many posts from newbies like my self, with over 200 views and not a single reply. No joke - This forum should have the title: Community & Support for Only a Select Few> :(.

   

Avatar
Fabrice Closier, Administrator
Posted: 27 June 2014 08:12 PM   Total Posts: 1265   [ # 3 ]

This is not a forum reserved for a few, except if you ment few “thousands” of course! Your issue is not really physics or away3d related. Its more an AS3 problem. That’s may be why you do not get answers, I dunno…

Anyway, I just discovered your request, so here goes my reply:

The error you get is pretty clear: do not call a method and construct at same time.
It’s either you do var something:AWPDynamicsWorld = new AWPDynamicsWorld(); or you call a method of this instance after it’s declared. The “getInstance” method is often the method name for a Singleton construction. Being often a public static method of a class, that returns a new instance of the same class if it does not exist yet, or creates one using new internally.

In your case, you do both. That’s incorrect AS3 and thats why the compiler is mad at you smile

   

Jillinger, Newbie
Posted: 28 June 2014 03:14 AM   Total Posts: 29   [ # 4 ]

Even though I don’t fully understand all that you said, I appreciate the reply. I will study it some more, an try to grasp it. Like I said, I was simply following examples of tutorials. I’ll look into it more carefully. Thanks
However, please don’t make excuses for the users of this board. I’ve been on many forums where someone didn’t post in the appropriate section, and they still received an answer along with a kind referral to the appropriate section. For example, how would I have known that I am not using the right section if you did not say. I would still be sitting here, hoping that someone reply, like some of those other users with over 200 views and no reply. Over 200…? Now come on… That’s ridiculous.

   

John Brookes, Moderator
Posted: 28 June 2014 10:28 AM   Total Posts: 732   [ # 5 ]

Fabrice has explained, but you would need to understand what construct and method mean.

So to explain in simple terms.

physicsWorld = new AWPDynamicsWorld.getInstance(); = WRONG

physicsWorld = AWPDynamicsWorld.getInstance(); = RIGHT

In none of the examples have you seen “new” before AWPDynamicsWorld.getInstance();

That is something you have mistakenly added.

   

Jillinger, Newbie
Posted: 29 June 2014 06:17 PM   Total Posts: 29   [ # 6 ]

You’re right - It was definitely a mistake on my part. I actually had to compare my code with another to realize that ‘new’ was not there.
However, I studied what Fabrice was saying, and I understand.
Thanks. I got my first rigid body test to work.grin

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X