PDA

View Full Version : item for running faster



Orindoomhammer
04-28-2010, 07:50 AM
ok what i want to set up is an object to make you run faster kinda like the jump boots only not consumable but only when you are holding down a button. where would i start, aside from making the item its self.

GeekyPayback
04-28-2010, 08:31 AM
These are the basics of how I'd do it

create a new class for your item, make it derive from the same parent as the jumpboots

Create a state in your controller class called Running. (simulated state Running extends PlayerWalking) Override the movement functions to be always moving forwards.

Create some exec functions in your player controller called StartRun and StopRun (and probably serverStartRun and serverStopRun)

In start run, check if the player has the item in their inventory. If they have increase the GroundSpeed and set the players state to "Running"

In stop run, set the GroundSpeed to default.GroundSpeed and set the state to none (? Is that the best for a player controller ?)

peam
04-28-2010, 09:02 AM
You can also exploit Pawn's event SetWalking( bool bNewIsWalking );

UTPawn always run but default Pawn can walk (by holding left shift).
Assuming bHasBoot is a bool variable telling whether your pawn has such a boot. You can override UTPawn like this:


event SetWalking( bool bNewIsWalking )
{
bNewIsWalking = !bNewIsWalking; // (hold left shift to run)
if ( bNewIsWalking != bIsWalking)
{
if (bHasBoot)
{
bIsWalking = bNewIsWalking;
} else
{
bIsWalking = true; // always walk if no boot
}
}
}

Orindoomhammer
04-28-2010, 09:06 AM
ok thats part of what im looking for but how do i set the speed? cause im not sure about that, i been picking apart utpawn everything. where would i set the speed. would that be in the speed booster?

peam
04-28-2010, 09:09 AM
Like GeekyPayback said you can set Pawn's GroundSpeed to alter pawn speed.
To change walking speed, change WalkingPct.

For example:
GroundSpeed=500
WalkingPct=0.5

running speed=500
walking speed=500*WalkingPct=250

Orindoomhammer
04-28-2010, 09:14 AM
ok so i can pretty much just use the speed-booster as empty and just have it say if i have it in the inventory and then just use it to change the default property?

peam
04-28-2010, 09:22 AM
Um... Whether you need to change GroundSpeed and WalkingPct is depending on your game design.

For example:
If your character cannot run without a boot. Use the previous code. There is no need to change GroundSpeed or WalkingPct at all during the game is running. Set your pawn's defaultproperties' GroundSpeed to your desired running speed when your character got the boot.

If you plan to allow your character w/o boot to be able to run as well (but not as fast as with the boot), you need to change that and the code would look like this:


// override UTPawn's
event SetWalking( bool bNewIsWalking )
{
bNewIsWalking = !bNewIsWalking; // (hold left shift to run)
if ( bNewIsWalking != bIsWalking)
{
bIsWalking = bNewIsWalking;
}
}

Then, change your Pawn's GroundSpeed and WalkingPct when obtain the boot.

Orindoomhammer
04-28-2010, 09:37 AM
yah its the second one. im not sure if you have played Super Metroid but im setting up a game that plays almost exactly like it. i have the side scroller aspect set up but in super metroid you can run but its just a bit faster then "walking" which for walking is quite fast. i would assume it would be more like sprinting.

when you pick up the speed boost it puts you in to a kinda warp run state that has a trail of your character behind you its quite awesome for a 2d side scroller. Right now im just trying to put the game play together ill worry about story and effects later. right now im just trying to get the game play down. its not easy as im not a coder.

but here is exactly what i want to do.

you can run and walk(default run speed) before picking up the item after you pick up the item it allows you to run at ever increasing speeds till you hit the "warp" speed which makes you invincible and can destroy certain objects in your path. if you abruptly Duck while running it will keep you in the "warp" state and allow you to put that energy to jump that is basically making you in to a projectile of sorts or continue running at "warp" speeds at your digression. the warp state will tick down while your not moving.

but most of this will be as i get better at scripting. right now i just wanna run fast lol.

Orindoomhammer
04-28-2010, 10:04 AM
ok it kinda works kinda doesn't the problem is when i hit terrain the animation screws up completely unless im holding down shift. other whys its works like i want it. default is slowish but holding shift down is faster.

peam
04-28-2010, 10:11 AM
Haven't play metroid though. But warp speed sounds fun. :)

Walking has something to do with other parameters like
bAvoidLedges
bStopAtLedges
bAllowLedgeOverhang
bCanWalkOffLedges

try the following combination, it might solve your problem...
bAvoidLedges=false
bStopAtLedges=false
bAllowLedgeOverhang=true
bCanWalkOffLedges=true

Orindoomhammer
04-28-2010, 10:12 AM
ok thank you. oh yes the speed boost was a blast and one of the more memorable items from that game.

Orindoomhammer
04-28-2010, 10:15 AM
ok that fixes alot of problems such as stopping at the ledges and what not. but it still makes me glitch on terrain. flat terrain to boot.

Orindoomhammer
04-28-2010, 10:17 AM
this is the speed booster in action in Super Metroid.

speedbooster in super metroid (http://www.youtube.com/watch?v=mq_jihEDWOE)

The SHINE SPARK (http://www.youtube.com/watch?v=r5b6XECRGqI&feature=related)

peam
04-28-2010, 10:26 AM
I am using this walk/run code but haven't got glitch on terrain though (may be my terrain is too simple).
So, you can just change groundspeed...


event SetWalking( bool bNewIsWalking )
{
if ( bNewIsWalking )
{ // left shift held
GroundSpeed = 1000; // run speed
} else
{ // left shift released
GroundSpeed = 250; // walk speed
}
bIsWalking=false;
}

Orindoomhammer
04-28-2010, 10:41 AM
AH OH YAH thats it man awsome and thank you so very much. that even fixed the terrain glitch.

now i just gotta fix it so when i pick up the item is only when it works. but for now this will work.

i have other control issues i must iron out. i wanna get this stuff fixed up before i start recruiting. right now im useing ut2d for the sidescroller stuff but the controls just dont work exactly like i want so i gotta figure out how to work it to bend the way i want.

but again im very happy this is working like it is. thank you very much.