Bomb tilts as it falls
by rennie moffat · in Torque Game Builder · 09/22/2009 (4:49 pm) · 4 replies
Edit, This code is designed to make a bomb fall from a plane. It sets the downward velocity and rotation of the bomb so it's nose rotates toward the ground upon release. My problem is that I also want it, the bomb to have an initial xVelocity @ creation/release. However, my setImpulseForce does not do the trick, any insight into what I may be doing wrong?
Bonus Question:
And a million points for anyone who can tell me how to link a %this.bombImpulseVelocityX to %this.planeVelocityX at any given moment.
Thanks
Bonus Question:
And a million points for anyone who can tell me how to link a %this.bombImpulseVelocityX to %this.planeVelocityX at any given moment.
Thanks
//-----------------------------------------------------------------------------
// Rennie Moffat
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
if (!isObject(BombRotateBehavior))
{
%template = new BehaviorTemplate(BombRotateBehavior);
%template.friendlyName = "Bomb Rotate";
%template.behaviorType = "AI";
%template.description = "Rotate the object";
%template.addBehaviorField(rotateSpeed, "The speed at which the object will rotate (degrees per second)", float, 30.0);
%template.addBehaviorField(rotationAmount, "max amount of rotation", int, 90);
%template.addBehaviorField(initialVelocity, "Ximpulse given to bomb @ creation", float, 100);
}
function BombRotateBehavior::onAddToScene(%this, %modifier, %worldPos)
{
%this.startRotation = %this.owner.rotation;
%this.owner.setAngularVelocity(%this.rotateSpeed);
%this.owner.setImpulseForce(%this.initialVelocity);
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
09/22/2009 (7:01 pm)
...edit to below.
#3
Even still tho, I did use your method, and nothing, any suggestions?
current code
09/22/2009 (7:06 pm)
Sorry, I just plugged it in and it still does not work. I would have thought that by setting it as a behavior field (initialVelocity, float, 100), as I did would work. Even still tho, I did use your method, and nothing, any suggestions?
current code
//-----------------------------------------------------------------------------
// Rennie Moffat
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
if (!isObject(BombRotateBehavior))
{
%template = new BehaviorTemplate(BombRotateBehavior);
%template.friendlyName = "Bomb Rotate";
%template.behaviorType = "AI";
%template.description = "Rotate the object";
%template.addBehaviorField(rotateSpeed, "The speed at which the object will rotate (degrees per second)", float, 30.0);
%template.addBehaviorField(rotationAmount, "max amount of rotation", int, 90);
%template.addBehaviorField(initialVelocity, "Ximpulse given to bomb @ creation", float, 30);
}
function BombRotateBehavior::onAddToScene(%this, %modifier, %worldPos)
{
%this.startRotation = %this.owner.rotation;
%this.owner.setAngularVelocity(%this.rotateSpeed);
%this.owner.setImpulseForce(%this.initialVelocity, 30);
}
#4
I have gone over this code, and tested. In testing I have noticed one thing. Neither my initialVelocity nor my rotationAmount behavior fields are working. No matter what they are set to the action remains the same. I would really like these two factors to play a role. If anyone has any insight, please let me know.
Thanks
Ren
09/23/2009 (10:33 am)
Hi, I have gone over this code, and tested. In testing I have noticed one thing. Neither my initialVelocity nor my rotationAmount behavior fields are working. No matter what they are set to the action remains the same. I would really like these two factors to play a role. If anyone has any insight, please let me know.
Thanks
Ren
Associate Phillip O'Shea
Violent Tulip