Jump to content

Determining Emitter Direction


Recommended Posts

If I'm trying to determine the direction of an emitter, for the purpose of applying a force relative to it's y axis, is there any way to do that?

I've tried every way I can think to determine the y axis of the emitter, but the only thing that seems to work is "this.rigidbody.AddRelativeForce(0,-particleEmitter.localVelocity.y,0 * appliedForce * 1)"

Honestly, that works pretty well, but I'm told that it's also "wrong". So, with that knowledge in hand I tried various other possibilities, like particleEmitter.localRotationAxis.y or particleEmitter.transform.rotation.y. None of those produce results.

I'd really appreciate some help in getting to the bottom of this. I'm running out of noodles to throw against the wall. :D

Link to comment
Share on other sites

Its local y axis in worldspace? According to the unity docs your way seems fine, although localVelocity has the qualifier "starting velocity". I would think rigidbody.transform.up or rigidbody.transform.rotation * Vector3.up would also give you correct results

Link to comment
Share on other sites

Its local y axis in worldspace? According to the unity docs your way seems fine, although localVelocity has the qualifier "starting velocity". I would think rigidbody.transform.up or rigidbody.transform.rotation * Vector3.up would also give you correct results

Hmm. Thanks for the tip. I gave it a shot but in this case unfortunately it resulted in a "[Exception]: NullReferenceException: Object reference not set to an instance of an object" error message.

I tried using both of the below, and both generated that same error.

this.rigidbody.AddRelativeForce(particleEffect.rigidbody.transform.rotation * Vector3.up * appliedForce * 1);

this.rigidbody.AddRelativeForce(valveEffect.rigidbody.transform.up * appliedForce * 1);

Something so simple as getting the vector direction of an emitter is surprisingly difficult. I'm still amazed that "particleEmitter.localRotationAxis" doesn't do anything.

Link to comment
Share on other sites

Hmm. Thanks for the tip. I gave it a shot but in this case unfortunately it resulted in a "[Exception]: NullReferenceException: Object reference not set to an instance of an object" error message.

It's probable that whatever particleEffect and valveEffect are, they don't have rigid bodies attached to them. Just use their transforms instead

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...