Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → More COG help please!!!
More COG help please!!!
2011-11-18, 9:09 AM #1
ok, i am working on eventually getting a friendly stormie to follow you around and fires at enemies... but right now i am just figuring out how to get an actor to follow you.

i have it working as of now so that if the actor is ever further than 0.3 distance from you it will move to your current location... but the problem it it moves to your exact location, bumping the player out of the way to get there. i want to get it so once the actor is within 0.3 of the player the actor will STOP...

any help??
Code:
symbols


message    startup
message    pulse


thing    player        
thing    trooper    


flex    movespeed=1.5
flex    thinkRate=1.0
flex    ctrlocator=0.30    local


vector    position0        local


end
# ========================================================================================


code


startup:
       AiSetMoveSpeed(trooper, movespeed);
    SetPulse(thinkRate);
    return;


# ........................................................................................


pulse:
    position0 = GetThingPos(player);
    if (VectorDist(GetThingPos(trooper), position0) < ctrlocator) {
        return;
    }
    else {
        AISetLookPos(trooper, position0);
        AiSetMoveThing(trooper, player);
    }
    if (GetHealth(trooper) <= 0.0) {
        SetPulse(0.0);
    }
    return;


end
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-18, 9:38 AM #2
as a side note i tried adding this with "ctrlocator1" defined as .25
but the actor does not follow the player at ALL now, regardless of how far away it is.
Code:
if (VectorDist(GetThingPos(trooper), position0) < ctrlocator1) { 
    StopThing(trooper)    
}
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-18, 4:30 PM #3
Post the version with the addition.
And when the moment is right, I'm gonna fly a kite.
2011-11-18, 5:55 PM #4
Code:
symbols


message	startup
message	pulse


thing	player		
thing	trooper	


flex	movespeed=1.75
flex	thinkRate=1.0
flex	ctrlocator=0.30	local
flex	ctrlocator1=0.25	local


vector	position0		local


end
# ========================================================================================


code


startup:
   	AiSetMoveSpeed(trooper, movespeed);
	SetPulse(thinkRate);
	return;


# ........................................................................................


pulse:
	position0 = GetThingPos(player);
	if (VectorDist(GetThingPos(trooper), position0) > ctrlocator) {
		AISetLookPos(trooper, position0);
		AiSetMoveThing(trooper, player);
	}
	if (VectorDist(GetThingPos(trooper), position0) < ctrlocator1) { 
		StopThing(trooper)	
	}
	if (GetHealth(trooper) <= 0.0) {
		SetPulse(0.0);
	}
	return;


end
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-18, 6:12 PM #5
hmm... also do you think something like this might be easier done with several cogs that just move the actors to different ghost positions throughout the level, like waypoints??
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-23, 6:33 PM #6
Originally posted by Darth_Alran:
hmm... also do you think something like this might be easier done with several cogs that just move the actors to different ghost positions throughout the level, like waypoints??

That's what I would do.
And when the moment is right, I'm gonna fly a kite.
2017-06-16, 12:12 PM #7
Originally posted by gbk:
That's what I would do.


I thought you'd ride the snake .
Star Wars: TODOA | DXN - Deus Ex: Nihilum
2017-10-21, 1:21 AM #8
Well, you should.
Star Wars: TODOA | DXN - Deus Ex: Nihilum
2021-02-23, 4:13 AM #9
Originally posted by Darth_Alran:
Code:
    if (VectorDist(GetThingPos(trooper), position0) < ctrlocator1) { 
        StopThing(trooper)
    }


bruh;
JKGR
2021-02-25, 7:19 AM #10
thanks bro
/end of endless suffering
幻術
2021-02-25, 11:01 PM #11
Damage control: I'm not gonna look at the main forum listing just to see "Last post by: Koobie"
Star Wars: TODOA | DXN - Deus Ex: Nihilum

↑ Up to the top!