PDA

View Full Version : This is embarrassing...


The Cobbler
05-27-2006, 02:18 PM
Hey all...just a fast question

I am trying to stop an instance from rotating when it hits the collision object.....current script is as follows:

if (particleShape1.event >= 1)

particleShape1.finalroto=<<0,rand(360),0>>;


Problem is I am having a brain freeze here with trying to remember what the proper tag is for grabbing just a whole number for the Y vector...the rand function just continues to rotate the objects on Y when they hit the ground....I just want to assign a random number like 4 and have it sit there...(there are lots of objects so they need a good range of random rotation)

Thanks in advance......I cant believe I'm askin this.

MikeRhone
05-27-2006, 02:58 PM
I feel like a fool for not quite understanding the question, BUT some random thoughts to get the noggin going:

To get a whole number, you can use

(int) rand(360) or trunc(rand(360)).

To get it to stop rotating, could you not just use "==" instead of ">="? Could there be any chance that it is calculating a collision on every frame because the instance is right on the ground plane?

On a seperate idea, instead of a collision event, have you considered using a mag(velocity) with an if statement to determine if the instance is at rest? Its not useable in all cases of course, but I prefer to avoid collision events if possible. Here is an example of what I mean:

http://www.wingman.ca/CgTalk/particleInstanceBlocks.mb

If I have your question wrong, please let me know.

The Cobbler
05-27-2006, 03:21 PM
Ahh...good call mate!....==

I have since got this to work using a noise(particleShape1.particleId)*10 in place of the rand(360)...but now that you mention the == Im pretty sure thats what was messing up the calculation....Ill go in and recheck that to confirm.

props for the quick reply....

And thanks

TheCobbler.

apoc519
05-29-2006, 05:55 PM
dan, dan, dan... have I taught you nothing?

your runtime is giving random rotational values on Y each frame after the first collision. If you want the rotation to stay static after the collision you probably want to reverse your if statement like this

if (particleShape1.event < 1)

rotation = <<random rotation>>;

then when the particle collides it will just hold the last rotation value because it doesn't get updated any more

CGTalk Moderation
05-29-2006, 05:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.