Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → changing a projectiles vector in a pulse
changing a projectiles vector in a pulse
2005-09-13, 11:30 AM #1
made a pic to show u what I mean.

You fire the projectile, and this projectile has a cog attached

Every pulse (of about 0.1 seconds) i need the projectile to "bend".

Now I will have a set of numbers to simulate a sine wave, but the sharpness of the sine wave will also be random.

I cant quite find the commands to change the getsenderref()'s vector.

Imagine the ancient drones from stargate, they fly as if they're an insect seeking out an enemy.

Hopefully you know what I mean.

the Commands I need is basically:

Change Vector ( x - (+ or -) flex * sinecount (simulate sine wave), y - (+ or -) flex * sinecount (simulate sine wave), z)

help and i will offer sweeties to all.
Attachment: 7233/proj.JPG (6,340 bytes)
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2005-09-13, 4:34 PM #2
SetThingLook(GetSenderRef(), NormalizedVector);


Use "ThingPulse" to set the pulse. NormalizedVector is the vector direction you want the object to look at.
And when the moment is right, I'm gonna fly a kite.
2005-09-13, 8:35 PM #3
look at yes, but travel? no

I tried and it just makes the projectile spin.

I need these projectiles to actually CHANGE direction slightly every pulse, ya dig daddiio?
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2005-09-13, 10:34 PM #4
Have you already come up with an equation to generate the wiggling look vector?

If so, after you set the look vector of the projectile (on the line below SetThingLook() if possible) use:
SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 5));
Where 5 is the speed you want the projectile to travel.

If not, search the forums for the sine functions and hopefully one of the sin/cos COG guys can help you get that junk working.

At worst you can probably fake the swerving calculations with a rotation of preset values to add to the thing's lookvector each pulse.

QM
2005-09-13, 11:01 PM #5
it works!

I used :

Old Vector = GetThingVel (original direction of the projectile)

New Vector = VectorSet((Sine func)Rand(), (Sine func)Rand(), (Sine func)Rand())

combined Vector = VectorAdd(old vector, new vector)

SetThingVel (projectile, combined vector)


And the result is fantastic.

Imagine hundreds of purple glowing orbs flying out and darting around like insects.

God bless the power of cog :)
Code:
if(getThingFlags(source) & 0x8){
  do her}
elseif(getThingFlags(source) & 0x4){
  do other babe}
else{
  do a dude}
2005-09-14, 3:38 AM #6
Giggedy. :o
And when the moment is right, I'm gonna fly a kite.
2005-09-14, 6:43 AM #7
Would you mind posting the exact code you used? I personally would love to be able to use a bending projectile.

↑ Up to the top!