Author Topic: How to make a melee weapon push a vehicle.  (Read 1714 times)

Kind of like what the hammer does. Basically I want my weapon, a golf club, to push a vehicle like the ball. How would one do this?

probably package onHit or whatever and if the weapon is golfClub addvelocity to the vehicle

That would have to be one damn big golf club to hit the ball, that things friggin huge.

But think's right on this one.

probably package onHit or whatever and if the weapon is golfClub addvelocity to the vehicle

How would I do this? I'm kind of new to Torque Scripting and the most I can do really is make basic weapons and vehicles.

How would I do this? I'm kind of new to Torque Scripting and the most I can do really is make basic weapons and vehicles.


package onHit
{
  //code here
};
activatePackage(onHit);


I'm not sure on that other one. Maybe this.


golfClub.addvelocity();

well you showed him what a package is and you somehow told it to add velocity to the golf club not the vehicle?

at least you used [tt]

package GolfClub
{
     function golfClubProjectile::onHit(%this, %obj, //Other variables, someone fill this in
     {
          //Vector code goes here, but I'm not good at maffs, someone help here too
          parent::onHit(%this, %obj, other variables);
     }
};
activatePackage(GolfClub);

well you showed him what a package is and you somehow told it to add velocity to the golf club not the vehicle?

at least you used [tt]
Hahaha, made me laugh

It's onCollision, not onHit.

if you want it to work like the hammer, just add velocity to it without much math:

randomVehicle.addVelocity("0 0 5");


if you want it to work like clicking the vehicle, it's slightly more complicated. i don't know exactly how to do it but it involves normalizing the player's position relative to the vehicle. try this:

%n1 = vectorNorm(vectorSub(player.position, vehicle.position));
vehicle.addVelocity(vectorScale(%n1, [the velocity you want the vehicle to move at]));


a good velocity might be around 30 or 40 on a small object

if you want it to move in the direction the player is looking (bad idea IMO):

vehicle.addVelocity(vectorScale(player.getEyeVector(), [velocity again]));

if you want it to work like the hammer, just add velocity to it without much math:

randomVehicle.addVelocity("0 0 5");


if you want it to work like clicking the vehicle, it's slightly more complicated. i don't know exactly how to do it but it involves normalizing the player's position relative to the vehicle. try this:

%n1 = vectorNorm(vectorSub(player.position, vehicle.position));
vehicle.addVelocity(vectorScale(%n1, [the velocity you want the vehicle to move at]));


a good velocity might be around 30 or 40 on a small object

if you want it to move in the direction the player is looking (bad idea IMO):

vehicle.addVelocity(vectorScale(player.getEyeVector(), [velocity again]));

First, it's vectorNormalize
Second, you don't have the slightest clue what it is or what it does

First, it's vectorNormalize
Second, you don't have the slightest clue what it is or what it does
vectorNormalize scales the vector so that all the numbers are between 0 and 1, the smallest being 0 and the largest being 1

vectorNormalize scales the vector so that all the numbers are between 0 and 1, the smallest being 0 and the largest being 1
You still don't have a clue

oh wait wait wait it's the ratio between them

0.5/1 = 50/100

am i rite or am i rong


No, really, I have no idea. Just basing that off of the posts in this topic.

0.5/1 = 50/100

try it yourself
use a calculator
both equal 0.5