Jump to content
  • The forum downloads section will be removed on Jan 1st 2023. Players may still download mods that are currently hosted, but new submissions are no longer being accepted. Mod makers are advised to relocate their mods to alternative hosting solutions.

Creature Mod Tutorial 4 - Locomotion 1.0


1 Screenshot

About This File

This tutorial will show you how to make your character run through the world!

Instructions on using the tutorial:

1. Download and extract the mod to your mods folder.

2. Open and follow the instructions in 'readme_tutorial_4.txt'.

Happy modding! :-)

  • Like 1

User Feedback

Recommended Comments

Hi... I know this is old but I was trying to follow this tutorials but at this step the creature actually don't run, I tryed to enable the mod from steam, just as is given to me, and don't works... I don't know how to make the creature to actually moves by itself, in the tuto says "And that's it!  Now our creature can move around the world.  Right now it looks more like sliding across the world but in our next tutorial, we'll look at how we can setup a stategraph to animate our creature based on it's movement." but the part about " Right now it looks more like sliding across the world" doesn't work :( help... and thank you!!

(as this is old I will give you a hand, here is the tut04.lua file, the prefab file):

Spoiler

--Here we list any assets required by our prefab.
local assets=
{
    --this is the name of the Spriter file.
    Asset("ANIM", "anim/tut04.zip"),
}

--This function creates a new entity based on a prefab.
local function init_prefab()

    --First we create an entity.
    local inst = CreateEntity()

    --Then we add a transform component se we can place this entity in the world.
    local trans = inst.entity:AddTransform()

    --Then we add an animation component which allows us to animate our entity.
    local anim = inst.entity:AddAnimState()
    
    --The bank name is the name of the Spriter file.
    anim:SetBank("tut04")

    --The build name is the name of the animation folder in spriter.
    anim:SetBuild("tut04")

    --Here we start playing the 'idle' animation and tell it to loop.
    anim:PlayAnimation("idle", true )

    --[NEW] We need to add a 'locomotor' component otherwise our creature can't walk around the world.
    inst:AddComponent("locomotor")

    --[NEW] Here we can tune how fast our creature runs forward.
    inst.components.locomotor.runspeed = 7

    --[NEW] We need to add a 'physics' component for our character to walk through the world.  Lucky for us, this
    --      this is made easy for us by the 'MakeCharacterPhysics' function.  This function sets up physics,
    --      collision tags, collision masks, friction etc.  All we need to give it is a mass and a radius which
    --      in this case we've set to 10 and 0.5.
    MakeCharacterPhysics(inst, 10, .5)

    --[NEW] We need to tell our creature which direction to run in.
    inst.components.locomotor:RunInDirection(270)

    --[NEW] And now we're ready to tell our creature to start running.
    inst.components.locomotor:RunForward()

    --return our new entity so that it can be added to the world.
    return inst
end

--Here we register our new prefab so that it can be used in game.
return Prefab( "monsters/tut04", init_prefab, assets, nil)

 

Link to comment
Share on other sites

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...