Author Topic: Animations playing at given speeds  (Read 8353 times)

I've been working on one of the main key features of the 3rd version of the Bolt; which was to make animated spoilers go up at given X speeds. However it hasn't been going so well because of how it turns out in-game:


Most of the beginning on spawn is correct. I made it in-code to where animated spoilers will animate themselves downwards when you spawn the vehicle. The spoiler when it's down is static; as in it doesn't rotate or move. In animations when transitioning up, the braking spoiler is revealed and the static spoiler hides and vise versa when going down. The braking spoiler is self explanatory. When the vehicle brakes, then the spoiler tilts like on a regular Veyron.

 

Yes I do know that in the front the lights are on and the taillights are off. This was on purpose because I had to remove the brakelight animations and toggable lights function temporary due to the fact that those functions may have been causing bugs that wasn't working along with this function.


The only problem with this is that the spoiler doesn't animate itself up when you're at X speed (X=# where if speed > X -> function). It stays down for the entire time and never animates up.




NightHawk, why can't you just hide those nodes using code instead of animations?

Mostly because CVS reasons. If I were to hideNode(Spoiler_A_D); (that's the static spoiler), when I select a different spoiler, or just click the wind spoiler again, I'm sure that that node that was just hidden will re-appear. That's why I use animations instead to hide those nodes to the original part for an advantage. I've done this before.



Here's the animations in the node editor. The problem for one thing that I've confirmed it's not the problem is animation order, but here's the order of animations for now:



If you can't see the markers, they're root:start, root:end, 164S-UP:start, 164S-UP:end, 164S-DOWN:start, and 164S-DOWN:end.

And here's the animation export settings all set up properly.





Here's the vehicle's code at this moment. I have modified it a bunch of times after experimenting with it and implementing options users have posted in this thread.

Bolt.cs

Code: [Select]

datablock TSShapeConstructor(Bolt_164_DTS)
{
baseShape  = "./Bolt 164.dts";
sequence0  = "./root.dsq root";
sequence1  = "./164SUP.dsq UP";
sequence2  = "./164SDOWN.dsq DOWN";
};


Code for importing animations.

Code: [Select]
function BoltVehicle::onAdd(%this,%obj)
  {
   Parent::onAdd(%this,%obj);
   %obj.hideNode(lhand);
   %obj.hideNode(rhand);
   %obj.hideNode(lhook);
   %obj.hideNode(rhook);
    
   %obj.playThread(0,DOWN);

   %obj.schedule(0,garageDefault);
  }

function wheeledVehicle::BoltSpeedCheck(%this, %obj)
{


     if(!isObject(%obj))
      return;

    %vehicle = %obj;
    
    %speed = vectorLen(%obj.getVelocity());
    if(!%vehicle.oldSpeed)
   %vehicle.oldSpeed = %speed;

    //Braking is not working currently
    //if(%vehicle.oldSpeed)
    //{
//if((%vehicle.oldSpeed - %speed) > 2) //Braking rate of speed in 500MS
//%applyBrakes = true;

//if(%speed < 1)
//%applyBrakes = false;
    //}

if(%speed < 0) //Keeps throwing random negative numbers when Aero is at dead stop
   %speed = 0;

%vehicle.oldSpeed = %speed;
//commandtoclient(%vehicle.getControllingClient(),'bottomprint', mFloor(%speed * 2) @"<color:FFFF00>BPS", 1);




//We use else if's so that it will find a true statement then skip the rest
if(%speed < 2) {
%vehicle.playThread(0,DOWN);
   }

else if(%speed > 65) {
   %vehicle.playThread(0,UP);
   }

//if(%applyBrakes)
//%vehicle.playAudio(1, AeroDrift);
//if(!%applyBrakes)
//%vehicle.stopAudio(1);

schedule(500,0,"BoltSpeedCheck",%this,%obj);
}
Functions for the Bolt. The first function hides the nodes for the hands (Hands On Vehicle Reasons) and then plays the down spoiler animation. The second function is where the problem somewhere in code is.



Basically from what I've said, I need help with this coding to where this happens:

X = already done and working thanks to me and you guys!

  • When spawned, the spoiler goes down [X]
  • At the given speed, the spoiler animates its way up, and hides the static spoiler. We can now have the option to see the brake animations while braking.[ ]
  • While the speed is greater than the starting given speed, we're able to use the wind brake. [ ]
  • When we've braked all the way to 0BLMPH, the spoiler goes down hiding the brake spoiler and showing the static spoiler, and braking animations on the brake spoiler are not visible. [ ]
« Last Edit: January 30, 2015, 03:38:49 PM by Night_Hawk »

So you have a static spoiler that has no animation and you're trying to hide it?

So you have a static spoiler that has no animation and you're trying to hide it?
The static spoiler is in the animations of moving the spoiler up and down. I'm hiding it using scaling.

If it's part of the up/down animation and still shows when it's up then I think there's an error in your animations. Perhaps Torque doesn't quite like scaling animations?

If it's part of the up/down animation and still shows when it's up then I think there's an error in your animations. Perhaps Torque doesn't quite like scaling animations?
Scaling animations works for me. After one frame (i.e if you're on frame 1 and frame two you're about to go to), the scaling instantly happens hiding the opposite spoiler. Again as I mentioned, I believe it's animation order.

Blender's exporter does not like scaling to 0.00000000 repeating.
If you are doing that, set it to something close to 0 but not 0.

forgot this is mainly the case when they start out in that size my bad

Anyways at the part where I gave my code. Is there something I need to change in order for the actual function to actually work if my animations were set up correctly?

wouldn't you have to call the sequence? try looking at other add-ons for reference
edit:
try putting the animation names in ""s instead of having them out.
e.i. DOWN -> "DOWN"
« Last Edit: January 06, 2015, 06:46:10 AM by Alphadin »

wouldn't you have to call the sequence? try looking at other add-ons for reference
edit:
try putting the animation names in ""s instead of having them out.
e.i. DOWN -> "DOWN"
I've been looking at other addons for reference. The addons that have the animation datablocks don't have those quotation marks that you gave an example about. Only quotation marks for where the sourcefile is located.

Anyways, I honestly don't think it's animation order anymore. I can really use some help here with my code guys. Remember, I want to make it so that when it reaches X BLMPH, the spoiler goes up, and then while the spoiler is up, and our speed is 0, the spoiler goes down.

Here's the code, I'll update the coding in the OP as well.

Code: [Select]
datablock TSShapeConstructor(Bolt_164_DTS)
{
baseShape  = "./Bolt 16-4.dts";
sequence0  = "./root.dsq root";
sequence1  = "./16.4S-DOWN.dsq DOWN";
sequence2  = "./16.4S-UP.dsq UP";
sequence3  = "./headlightON.dsq ON";
sequence4  = "./headlightOFF.dsq OFF";
};

Code for importing animations

Code: [Select]
package BoltFunctions
{
  function BoltVehicle::onAdd(%this,%obj)
  {
    Parent::onAdd(%this,%obj);
    %obj.hideNode(lhand);
    %obj.hideNode(rhand);
    %obj.hideNode(lhook);
    %obj.hideNode(rhook);
   
    %obj.hideNode(lightsON);
    %obj.hideNode(brakeOFFLIGHT);
   
    %obj.playThread(0,OFF);
    %obj.playThread(0,DOWN);

   %obj.schedule(0,garageDefault);
  }
 
  function serverCmdLight(%client)
{
if(isObject(%client.player) && !isObject(%client.player.light))
{
%player = %client.Player;
%carlight = %player.getControlObject();

if(isObject(%carlight))
if(%carlight.getDatablock() == BoltVehicle.getID())
{
if(%carlight.door == 1)
{
%carlight.door = 0;
%carlight.unhidenode(lightsOFF);
%carlight.unhidenode(brakeOFF);
%carlight.hidenode(lightsON);
%carlight.hidenode(brakeOFFLIGHT);
%carlight.playThread(0,OFF);
}
else
{
%carlight.door = 1;
%carlight.unhidenode(lightsON);
%carlight.unhidenode(brakeOFFLIGHT);
%carlight.hidenode(lightsOFF);
%carlight.hidenode(brakeOFF);
%carlight.playThread(0,ON);
}
return;
}
}
parent::serverCmdLight(%client);
}

function BoltSpeedCheck(%this, %obj)
  {


     if(!isObject(%obj))
      return;

    %vehicle = %obj;
   
    %speed = vectorLen(%obj.getVelocity());
    if(!%vehicle.oldSpeed)
    %vehicle.oldSpeed = %speed;

    //Braking is not working currently
    //if(%vehicle.oldSpeed)
    //{
//if((%vehicle.oldSpeed - %speed) > 2) //Braking rate of speed in 500MS
//%applyBrakes = true;

//if(%speed < 1)
//%applyBrakes = false;
    //}

if(%speed < 0) //Keeps throwing random negative numbers when Aero is at dead stop
    %speed = 0;

%vehicle.oldSpeed = %speed;
//commandtoclient(%vehicle.getControllingClient(),'bottomprint', mFloor(%speed * 2) @"<color:FFFF00>BPS", 1);




//We use else if's so that it will find a true statement then skip the rest
if(%speed < 2) {
%vehicle.playThread(0,DOWN);
    }

else if(%speed > 65) {
    %vehicle.playThread(1,UP);
    }

//if(%applyBrakes)
//%vehicle.playAudio(1, AeroDrift);
//if(!%applyBrakes)
//%vehicle.stopAudio(1);

schedule(500,0,"BoltSpeedCheck",%this,%obj);
  }
};
activatePackage(BoltFunctions);
Package for Vehicle's Functions

If I can't get this fixed I'm going to have to go to my alternative plan and use a custom key bind to activate this spoiler.

Since I can't figure out how to do this nor I couldn't get help. I've decided to say screw it with the speed animation functions and toggle the spoiler with the crouch (shift) key as I said in my topic. Locking this and I may make a topic later in the future.

Quote from: OP
I've decided to just open this back up after getting a PM of advice and seeing this thread. I'll continue to look into using speed to toggle that spoiler, but later on I'm going to rewrite this whole topic because reasons.
« Last Edit: January 25, 2015, 10:25:23 PM by Night_Hawk »

I apologize if I'm cross posting, but I thought I'd leave this here now since the topic was locked. I think this can help, I'll edit this post replying to these quotes below if the possible solution isn't working.

I believe that I may have solved your problem. Instead of calling the schedule like you are currently doing, use this.

%obj.schedule(500, boltSpeedCheck)

The way that you are currently calling it tells the game that it is not an object schedule. I believe that this is the solution.

But on another note, you're totally wrong about this.
Look at the function declaration:
Code: [Select]
function BoltSpeedCheck(%this, %obj)
It's not a method on an object, it's just a regular function.
You'd be right if it was like this:
Code: [Select]
function wheeledVehicle::BoltSpeedCheck(%this, %obj)
(Not sure if wheeledVehicle is the right class name, but it's just an example)


Both options don't seem to be working right now, but what I plan to do later on is to take out ALL animations and just start by making the root, and the spoiler animations of going up and down. Also thinking about taking down the toggable lights function and maybe taking out the package of bolt functions and making them separate.
« Last Edit: January 26, 2015, 08:45:54 AM by Night_Hawk »

I apologize if I'm cross posting, but I thought I'd leave this here now since the topic was locked. I think this can help, I'll edit this post replying to these quotes below if the possible solution isn't working.


Both solutions don't seem to be working right now, but what I plan to do later on is to take out ALL animations and just start by making the root, and the spoiler animations of going up and down. Also thinking about taking down the toggable lights function and maybe taking out the package of bolt functions and making them separate.
I wasn't giving you a solution at all. I was pointing out why Darksaber's solution was 100% wrong.

I wasn't giving you a solution at all. I was pointing out why Darksaber's solution was 100% wrong.
Well I guess I ment to say option...

Anyways what is it I can do to fix that option Darksaber suggested, or should I just take it out of code?
« Last Edit: January 26, 2015, 08:49:31 AM by Night_Hawk »

Well I guess I ment to say option...

Anyways what is it I can do to fix that option Darksaber suggested, or should I just take it out of code?
There is no way to fix what he said, because everything he said was wrong. What he said isn't why your code isn't working.