Jump to content

Recommended Posts

  • Developer

The recommended way to mod player speed is with this:

 

inst.locomotor:SetExternalSpeedMultiplier(inst, "illya_speed_mod", 2)

 

2 is the multiplier in this example, so you will move twice as fast.

"illy_speed_mod" is any unique key you want, in case you need to use it to remove or change the bonus later.
(e.g. inst.locomotor:RemoveExternalSpeedMultiplier(inst, "illya_speed_mod")

 

But what If I wanted my character to walk slow on roads and fast on turf?

 

The road speed multiplier is 1.3, as stated in the fastmultiplier member of locomotor.

 

First, in order to make your character be faster everywhere, including turf, we do

inst.components.locomotor:SetExternalSpeedMultiplier(inst, "turf_speed_mod", 2)

in the master_postinit function of the character.

 

Now that the character is faster everywhere, we do

AddComponentPostInit("locomotor", function(self)	if self.inst.prefab == "wilson" then		self.fastmultiplier = 0.7	endend)

in the modmain.lua file of your mod, with "wilson" being your character prefab.

 

Notice we replaced 1.3 for 0.7, so roads will reduce your character's speed.

I tried applying this to my character but she still is blazing fast on both turf and road. Ideas?

 

Apparently the prefab name isn't setup at the time.

 

Put a tag like roadslow on the common_postinit and then use

AddComponentPostInit("locomotor", function(self)    if self.inst:HasTag("roadslow") then        self.fastmultiplier = 0.7    endend)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...