ID:1906768
 
(See the best response by Kaiochao.)
So basically in my game I have it where when you select a race your character enters the world, and when that happens a follower appears being your familiar or pet. I tried looking at demos and other questions on how to do a simple command and follow thing, but most had a bunch of coding that turned out to be wrong and I did not just want to copy and paste something I did not completely understand. Can anyone help me?
Code:
mob
Beasts
icon='Beasts.dmi'
Bat
icon_state = "Bat"




Best response
The simplest way is walk_to(your_follower, you) but if you don't like that, you'll have to do something else. Add the follower to your group var to use special group-related collision resolution.
If you're only taking 1 step at a time, you can probably get away with calling a follow function on your follower every time your mob takes a step. Pseudocode

mob/Move()
// Take step
// Access follower follow proc

mob/follow(mob)
// Step towards mob


Obvious breakdown with teleporting.
I am confused
In response to Dayvon64
What part are you confused about?
Would this be it?

mob
Beasts
icon='Beasts.dmi'
Bat
icon_state = "Bat"
mob/follow(mob)

Add the familiar to your group using Owner.group.Add(Familiar) you can place it in what ever code spawns it, such as
mob/verb/Familiarpls()
var/mob/Beasts/Bat/B=new/mob/Beasts/Bat//Create a bat
usr.group.Add(B)//Add it to users group

Then in Move() you could tell it to step with you, like so
mob/Move()
if(client)//If player
for(var/mob/Beasts/B in group)//Check for familiar in group
step_to(B,src)//Make them step towards you
So like this

mob
Beasts
icon='Beasts.dmi'
Bat
icon_state = "Bat"

mob/verb/Familiarpls()
var/mob/Beasts/Bat/B=new/mob/Beasts/Bat//Create a bat
usr.group.Add(B)//Add it to users group

mob/Move()
if(client)//If player
for(var/mob/Beasts/B in group)//Check for familiar in group
step_to(B,src)//Make them step towards you
Yes, I suppose. You copied what I had put up as an example, so I don't know if you grasp the concepts. If you have trouble let me know.
It would probably be best to make a list of all the pets the player has so something like this.
  mob
var
list/Pets

Then adding a pet
mob/verb/AddPet()
var/mob/Beasts/Bat/B=new/mob/Beasts/Bat//Create a bat
src.Pets.Add(B)//Add it to users group

Then the movement, make sure you call ..() otherwise your player won't move.
mob/Move()
if(client)
for(var/mob/Beasts/B in Pets)
step_to(B,src)//Make them step towards you
..()
Everytime I try to do it, it doesnt work
@Colesprite, you are moving the pets toward the player before calling the default action.

This is the third time I've said this this week, you MUST set the return value in Move() or it will always fail.

mob/Move()
. = ..()
if(.&&client)
var/d
for(var/mob/Beasts/B in Pets)
var/d = bounds_dist(B,src)
if(B.z!=z&&d>=512)
B.loc = loc
B.step_x = step_x
B.step_y = step_y
else if(d>=B.step_size)
step_to(B,src)


Even with my improvements, this is a really problematic example.

The mobs should have their own pathfinding or be force-following the player properly. Moving them every time the player moves is not good enough.
You can do a pokemon-style movement where the mob is always one tile behind you.

mob
var/mob/follower

Move(turf/turf)
var/turf/old_loc = loc
. = ..()
if (. && follower)
follower.loc = old_loc