Skip to main content
gamedev.net
🔒 Locked

Movement Scripting

Started by Kosh 12 replies 1.2k views
Original Post
Kosh
Kosh
Hi everyone, I am looking into creating a movement scripting engine, something that can move an object according to a simple algorithm. Like a sine wave, or a b-spline. But I want these handled in a generic fashion, so coding a specific function for each of these is not entirely what I had in mind. But what about an engine that would take in parameters and move the object in accordance to these parameters and equations ? thats what I want I wanna know, does anyone have thoughts, URL''s, references to such a system, or such information. Thanks kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
Spellbound
Spellbound
You may want to check up on NURB curves. These are the perfect mathematical tool that can describe any, and I mean any, curve with parameters.

They are not that easy to understand though. I have decrypted them myself but it gave me a headache (metaphorical speaking) doing so, and I have a MSc degree in computer science (except for a few weeks ).

Edited by - Spellbound on 3/17/00 2:24:13 PM
Kosh
Kosh
hello all,

right, so NURBS, thats a good idea, also, can nurbs desribe a curve that is in fact a straight line ? in other word, can I use a NURBS system to move an object along a curve just as easily as using the same system to move an object in a straight line ? anyone know what I mean ?
if understanding it made and born with time, then time, is understandings greatest enemy.....
SiCrane
SiCrane
If you feed a NURB a set of points in a straight line you''ll get an overly complex straight line equation.
Kosh
Kosh
hello all,
But I am needing a way of moving an object in the following ways
Straight lines,
Curves (weighted or not)
Right angled movements.

Also, I must be able to define parameters to define what an object must do given a situation, for example, I must be able to say, that an object can move in so and so way, BUT if the object encounters, say, another object, or even a wall (defined by me) it has to do such and such (this is open ended cause it''s really up to you what situations you can put this through)

Therefore, this is a scripting engine, I just give it a movement equation, it moves, then I send that object information about what to do in a given situation, define that situation, then not worry about the movement of the object, since I know it''s going to do what I defined.

Does anyone understand that ? cause I am getting a little confused myself here haha

kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
SiCrane
SiCrane
Maybe you should just consider a way-point based movement system. Then when assigning your curved movement, create waypoints along the curve you want.
Kosh
Kosh
hello all,
yeah, sicrane, you have something there, thats a definte idea to look into. thanks.
But I think I am having more trouble with working out a robust but yet dynamic way of being able to move an object in any way that I feel like, I specified the types of movement that I want, a waypoint system sounds ok idea, but I would have to specify all the waypoints for possibly all the objects, that sounds like a lot of work when comparing that to moving the objects in accordance to an equation with restricting rules, you know what I mean ?

kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
SiCrane
SiCrane
Well, when specifying you want to move along the a curve with some function f(), have the movement function automatically create the way points. That way you, the scripter, will still be saying move along a sine, but the internals will be thinking move from waypoint to waypoint. Once you''ve broken it down to lots of point-to-point movements, wall problems and object intersections will be relatively simple issues.
Kosh
Kosh
hello all, and bloody geniuses

yeah, I can do

CreateMovementScript(function, target_object);

or something similar. that then takes the function, derives waypoints from it, sets the information in target_object and then when I call

MovementScriptObject(target_object);

it will have waypoint information in it, stored in an array of waypoints, information for curves, if needed.

That sounds like a great idea.

OK!! now for the hard stuff, I have to figure out a way that will allow me to define the movement of an object with respect to an equation. Can anyone advise me (probably sicrane reading this aint it you little bugger on the best way to implement this system (I know this is turning into a discuss my problem and help me develop this system type question, but I dont think I''ll be shot for that). Do you know of any way that this can be implemented easily ?

thanks

kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
SiCrane
SiCrane
Well, each kind of curve will have a different set of necessary parameters.... I would recommend creating a class to encapsulate each different kind of curve. Then have the curve classes create the waypoints.

Each would probably take the starting point and ending point for the object. Or maybe just a starting point and a direction vector or something. As well you might need to specify the resolution of the function. Like 100 way points or 10 waypoints or something.

For example let's take the sine function (assuming 2d).
Additional parameters might include amplitude of the wave as well as frequency of the wave form. (number of humps between start and end).
So taking the start point and the end point, we have a direction vector v. We can create a normal vector n to the direction vector.

Then each waypoint can be described as
w[ i ] = v * (i / N) + n * A * sin(k * 2 PI * i / N)

where v is the direction vector
n is the normalized normal vector
k is the number of humps
N is the number of way points.
i is the number of the way point.
A is the amplitude of the sine wave.

v and n can be derived from start and end points, N should be a common parameter for all classes, so you need to specify k and A for your class.
For a sine wave N should be greater than 2 * k, otherwise it might not look like a sine wave as you won't get enough sampling. I would in fact recommend N greater than 4 * k.

This post edited to get rid of forum mangling.

Edited by - SiCrane on 3/18/00 2:54:55 AM
Kosh
Kosh
sounds excellant.

one question, where do you guys find resources on the web ? where do you find papers or research documents about this sort of stuff ?

just wondering, thanks

kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
Kosh
Kosh
hi HAK, why dont you register, then I could see your name without you having to tell me.

something I thought about now, movement scripting is really really high level, more complex movement only, you try and use movement scripting to say, move a sprite along a mathematically created path, then for this you dont really need movementscripting do you ?

can anyone here give me some examples of when movement scripting would be used and some that wouldnt.

I just wanna get a grasp for the technology and see if there are anyone out there that has ideas on where this tech could be used, thanks

kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.