123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|700|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Moving an entity in a wavy pattern

Mon, 07 Jul 2008, 18:56
Orion Pax
I need to make some entities in blitz move but in a wavy pattern. I need it to go straight but sway left and right.

Right now I am just counting in a loop and reversing the turning direction after so many loops. I am sure there is a better way but I dont know.
Mon, 07 Jul 2008, 19:06
Scherererer
use a sin wave!
Mon, 07 Jul 2008, 19:27
Orion Pax
I figured that was it but I have no idea how to do a sin wave. I guess I do a sin on my entities yaw value?
Mon, 07 Jul 2008, 19:44
Scherererer


here's a simple pendulum-type-motion as an example if you get stuck

|edit|
Yeah you could set the yaw value to the output of the sin function. notice in my example i multiplied the sin value by 150: that's because it only goes from 0.0000-1.0000, so if you want a more intense change, you have to add a larger multiplier. so, if you want to move in a variance of 15 degrees, you'd set it to 15*Sin(theta#)
|edit|


-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Mon, 07 Jul 2008, 20:07
Orion Pax


Ok I do this but it goes back and forth much to the right. And none to the left.
Mon, 07 Jul 2008, 23:04
Scherererer
aha! i didn't figure it out until i remembered calculus: in your scenario, you have the sine curve acting as the velocity graph, in mine its the position graph. What that means is, that your object's velocity is going from 1 to -1, whereas my position is going from -1 to 1. Therefore, your object's position is the integral of the sin function, being a cosine function. Now, the function with the integral that is a sine graph, is, of course, cosine.

long story short, change Sin to Cos



-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus