Help with substituting PlayerObject...?
by Robert Carroll · in TGB Platformer Kit · 09/28/2011 (3:08 pm) · 0 replies
So, I'm trying to re-lean what little .cs I learned but have a problem with this:
This is the original... I did this trying to make said object with this behavior fallow the player.
Can someone tell me what I have to put in order for this to work?
P.S. after I did this my player fell through everything.
if (!isObject(MoveTowardBehavior))
{
%template = new BehaviorTemplate(MoveTowardBehavior);
%template.friendlyName = "Move Toward";
%template.behaviorType = "AI";
%template.description = "Set the object to move toward another object";
%template.addBehaviorField(object, "The object to move toward", object, "", t2dSceneObject);
%template.addBehaviorField(speed, "The speed to move toward the object at (world units per second)",
float, 2.0);
%newObject.spawnOnRemoveCount = %this.count;
}
function MoveTowardBehavior::onAddToScene(%this)
{
%this.owner.enableUpdateCallback();
}
function MoveTowardBehavior::onUpdate(%this)
{
if (!isObject(%this.object))
return;
%this.owner.moveTo(%this.object.position, %this.speed);
}This is the original... I did this trying to make said object with this behavior fallow the player.
if (!isObject(MoveTowardBehavior))
{
%template = new BehaviorTemplate(MoveTowardBehavior);
%template.friendlyName = "Move Toward";
%template.behaviorType = "AI";
%template.description = "Set the object to move toward another object";
%template.addBehaviorField(speed, "The speed to move toward the object at (world units per second)",
float, 2.0);
%newObject.spawnOnRemoveCount = %this.count;
}
function MoveTowardBehavior::onAddToScene(%this)
{
%this.owner.enableUpdateCallback();
}
function MoveTowardBehavior::onUpdate(%this)
{
if (!isObject(%this.PlayerObject))
return;
%this.owner.moveTo(%this.PlayerObject.position, %this.speed);
} Can someone tell me what I have to put in order for this to work?
P.S. after I did this my player fell through everything.
About the author
Stay Up all night playing PS3 ;) add me PSN: RCBASEBALL13.