The Daily Click ::. Forums ::. Klik Coding Help ::. Pendulum motion effect?
 

Post Reply  Post Oekaki 
 

Posted By Message

Individual Thought

Dances with Pixels

Registered
  30/08/2002
Points
  79

VIP MemberWii Owner
9th November, 2004 at 20:55:31 -

Does any one know of a good method to create a pendulum motion effect without having to draw active objects frame by frame, or by using the retarded path movement in TGF?

Image Edited by the Author.

 
Currently and mainly working on my fantasy epic entitled: Drawn Sword.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
10th November, 2004 at 05:08:24 -

What, you mean realistic physics? Get a physics textbook describing how pendulums swing. You should be able to figure out the X and Y coordinates from there...

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
10th November, 2004 at 17:44:18 -

Parabolas (or curves) that have a minimum value (open upward) have the general equation of: (x-h)^2 = p(y-k), where the vertex (lowest point in this case) is at the point (h,k), and p is a number greater than 0. So to find the y position at a given x-coordinate of the parabola: y= ((x-h)^2 / p) + k. You can go back and forth between a range of x values to acheive a swinging effect. You'll want the pendulum's speed to be inversely proportional to its horizontal distance from its center value. Fiddle around with the p term to achieve the arc you want. For the pendulum's bar, you might be able to use the DrawLine object. See, math is useful.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
10th November, 2004 at 19:22:40 -

FYI: the horizontal position of the pendulum will follow a sine wave.

 
n/a

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
10th November, 2004 at 21:16:54 -

You could use a circular function.
...................__________________
set y= 0-( \/ (X+r)^2 - (X+r) ^2 ) + constant

Where R is the radius.

You could have a value called D that acts as a x displacer like when you make a custom platform movement.
Let ( Y = Y + D )

Use a flag.

If D >-5 &
flag off --- D = D-1

If D <5 &
flag on --- D = D+1

If D = 5 --- set flag off

If D = -5 --- set flag on



Please, if you use this, gimi some credit! (That took a bit to figure out)

Image Edited by the Author.

 
n/a

JP



Registered
  07/06/2003
Points
  1338
10th November, 2004 at 21:22:54 -

or you could make a path object to go in a curve and adjust the speed accordingly, then use the draw line object...

 
Steve Zissou: Anne-Marie, do all the interns get Glocks?

Anne-Marie: No, they have to share one.

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
10th November, 2004 at 21:28:53 -

Nah, the completely unessasaraly complicated math is better!

(I just realised that the technique I mentioned earlier would not stop swinging)
You'd need to have a limiter on the number 5 there.

Replace the number 5 with a value Lets say 'E'. And decrease it every second or so.

Add this in

Set E to 5
every sec ( e = e - 1 )

( Change 'If d<5' to 'If d<E' and 'If d>-5' to 'Id D> 0-E' )

Image Edited by the Author.

 
n/a

Individual Thought

Dances with Pixels

Registered
  30/08/2002
Points
  79

VIP MemberWii Owner
10th November, 2004 at 22:42:48 -

Im still having trouble. I still can't understand what exactly to do? Man im stupid.

Image Edited by the Author.

 
Currently and mainly working on my fantasy epic entitled: Drawn Sword.

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
11th November, 2004 at 18:08:04 -

Either that or that stuuf I said is rediculously complicated.
Which it is.

 
n/a

Airflow

imafirinmahlazr

Registered
  24/09/2003
Points
  -197

VIP MemberSonic SpeedSnow Cloud!Computer
11th November, 2004 at 21:23:21 -

I'll write an article.- That other stuff I said before was wrong anyway.
( I used the wrong equasion)



Image Edited by the Author.

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click