|
BigDaz
|
 |
« on: April 15, 2009, 02:52:15 PM » |
|
I'm trying to get a rotor of a helicopter to spin around, I thought I could use the same script as the vehicle does for turning its wheels with a bit of modification. So I've got
void AnimAdvance( Object@ object, float seconds, float interpAmount) { if (!object.IsVisible()) return;
Vector position; Vector rotation; ObjectBase@ wheel;
@wheel = MainRotor; rotation = wheel.GetRotationEuler(); rotation.x += 20 * seconds; wheel.SetRotationEuler( rotation); }
I'm getting Null pointer access error on the line rotation = wheel.GetRotationEuler();
What does this mean and how can I fix it? All I want it to do is get a model to spin around really.
MainRotor is declared as ObjectBase@ MainRotor;
|
|
|
|
|
Logged
|
|
|
|
|
acocq
|
 |
« Reply #1 on: April 15, 2009, 05:30:51 PM » |
|
Not sure if I can really help (haven't gotten into GC programming yet), but here are some ideas:
I would venture a guess that WHEEL is not intialized properly (i.e. it is a NULL, instead of a pointer to your object).
Where is MainRotor defined ? What is its scope (local or global) ?
What's the value of MainRotor when you are in the AnimAdvance routine ? If it is NULL, then obviously it's not "visible" to the AnimAdvance routine.
Cheers, Andreas
|
|
|
|
|
Logged
|
__________________________ Easy to use ... is easy to say ! 
|
|
|
|
Ron
|
 |
« Reply #2 on: April 15, 2009, 06:01:20 PM » |
|
This method might work for what you need, its from the weapons script
float rotateSpeed = 1500.0; GetGameManager().GetWorld().GetObject( "MainRotor").GetCurMatrix().Rotate( seconds * rotateSpeed, 0, 0);
|
|
|
|
|
Logged
|
|
|
|
|
gekido
Guest
|
 |
« Reply #3 on: April 16, 2009, 01:51:59 PM » |
|
Another place to look is the example door.gsl script from the default library - it's basically rotating the object around it's center point - basically the same idea as what you are looking for.
|
|
|
|
|
Logged
|
|
|
|
|
Spaz
|
 |
« Reply #4 on: April 16, 2009, 02:54:20 PM » |
|
Gekido,
Didn't you have a working blackhawk helicopter in an old demo? It was just an AI chopper following a path, but the rotor blades worked, didn't they? Or was that just an animation built into the model?
|
|
|
|
|
Logged
|
|
|
|
|
BigDaz
|
 |
« Reply #5 on: April 16, 2009, 05:38:07 PM » |
|
Thanks. I've got got it working, my code was actually fine it just needed the line @MainRotor = object.GetObjectBase( "MainRotor"); added at the initialisation stage. http://www.vimeo.com/4188295(The sound was dubbed on afterwards) I think it might be a good idea to have it start up and once the rotor is up to full speed, swap the model for simpler one more suited to moving.
|
|
|
|
« Last Edit: April 16, 2009, 05:41:16 PM by BigDaz »
|
Logged
|
|
|
|
|
Ron
|
 |
« Reply #6 on: April 16, 2009, 07:11:10 PM » |
|
Glad you got it working, that looks really good. The control and movement look perfect.
|
|
|
|
|
Logged
|
|
|
|
|
hikmayan
|
 |
« Reply #7 on: April 16, 2009, 10:29:21 PM » |
|
Looking good man....keep the good work. 
|
|
|
|
|
Logged
|
You have to be in it.....to win it!
|
|
|
|
Spaz
|
 |
« Reply #8 on: April 17, 2009, 11:29:32 AM » |
|
That looks fantastic, BigDaz! The movement looks really good. Any chance you'd share your script?
|
|
|
|
|
Logged
|
|
|
|
|
BigDaz
|
 |
« Reply #9 on: April 17, 2009, 03:00:12 PM » |
|
Yeah, it doesn't really work at the moment other than but I'll share it if/when it's completed.
|
|
|
|
|
Logged
|
|
|
|
|
gekido
Guest
|
 |
« Reply #10 on: May 20, 2009, 12:47:04 PM » |
|
The blackhawk just had an animation playing to make the blades spin. It wasn't quite sufficient though, so what I'm doing for the updated version is having an animation for the 'start up' sequence, and then swapping it for a 'blurred' plane to simulate the spinning blades at full speed.
|
|
|
|
|
Logged
|
|
|
|
|
Squat
|
 |
« Reply #11 on: May 21, 2009, 01:22:11 PM » |
|
Might I suggest a faded transition between the spinning model and the flat blurry plane? The quick switch just comes out nasty and it's that way in practically every game with a chopper.
|
|
|
|
|
Logged
|
|
|
|
|