Speed power up?
by Adam Troutman · in Technical Issues · 05/15/2006 (8:22 pm) · 5 replies
Okay I have been working on this speed power up and this is what I have
The run force seems like it is getting changed and the run and walk speed say they are being changed but I am seeing no speed increase at all.
function coke::onPickup(%this,%obj,%user,%amount)
{
%player = %user;
%data = %player.getDataBlock();
%client = %player.client;
if (%data.maxForwardWalkSpeed = 7)
{echo(%data.maxForwardwalkSpeed);
echo("walk speed should be raised");
%data.maxForwardWalkSpeed = (%data.maxForwardWalkSpeed * 100);
echo(%data.maxForwardwalkSpeed);
}
if (%data.maxForwardrunSpeed = 7)
{
echo(%data.maxForwardrunSpeed);
echo("run speed should be raised");
%data.maxForwardrunSpeed = %data.maxForwardrunSpeed * 100;
echo(%data.maxForwardrunSpeed);
}
if (%data.runForce = 48 * 90)
{
echo("run force should be raised");
%data.runForce = (%data.runForce * 100);
echo(%data.runforce);
}
}The run force seems like it is getting changed and the run and walk speed say they are being changed but I am seeing no speed increase at all.
#2
05/16/2006 (12:51 pm)
Okay, I guess I won't make that then but I still would like to know why I didn't see a speed increase.
#3
05/17/2006 (3:16 am)
Inside the engine code it needs to run the onDatablockChange (or whatever the name). If that code is never called and/or if the code doesnt include re-reading those exact changed variables then that would be why
#4
And for walking you could define your speed with somthing like this...
walkforwardspeed = PlayerShape.maxForwardSpeed - 5;
and the same for back and side speed. you could probaly figure out how to use walk speed.
If you were to copy from "//default run speed 10" to "jump higher" into your collision function for your object it would work. Hope this helps.
05/24/2006 (7:23 am)
I'm doing something like that but with a strength upgrade that increases speed, damage given, jump height and lowers the time delay when I hit the ground. You find all this info in your /Torque/SDK/Engine/Game folder in your player.cc file. Here is a code snippet from my strength upgrade..........
//My collision function
function StrengthUpgrade::onCollision(%this, %obj, %col)
{
//make sure its the main player that got it;
if(%col.getClassName() $= "Player")
{
echo("found strength upgrade");
%obj.delete();
//make him run faster for each one he picks up
//default run speed 10
PlayerShape.maxForwardSpeed++;
PlayerShape.maxBackwardSpeed++;
PlayerShape.maxSideSpeed++;
//default under water run speed 8
PlayerShape.maxUnderwaterForwardSpeed++;
PlayerShape.maxUnderwaterBackwardSpeed++;
PlayerShape.maxUnderwaterSideSpeed++;
//jump higher
PlayerShape.jumpForce += 2;
PlayerShape.recoverDelay--;
PlayerShape.upMaxSpeed++;
}
}And for walking you could define your speed with somthing like this...
walkforwardspeed = PlayerShape.maxForwardSpeed - 5;
and the same for back and side speed. you could probaly figure out how to use walk speed.
If you were to copy from "//default run speed 10" to "jump higher" into your collision function for your object it would work. Hope this helps.
#5
05/24/2006 (7:25 am)
Yeah thanks for writing all that I dont have the engine yet though :( soon lol soon.
Torque Owner Thomas \"Man of Ice\" Lund
Changing the datablock makes the speed go up for ALL objects using that datablock.
So basically hack the engine to include some setSpeed(), setMaxSpeed() or whatever console functions that raise the speed for the given object instead.