Need help whit movement from collision
by Conny Landstedt · in Torque Game Builder · 02/05/2009 (9:20 am) · 1 replies
Hi, I would like to get some help whit a problem I have in TGB. I am very new to this engine so I am having a hard time figuring out how to do a lot of stuff. Mostly I am having problems trying to get my scripts to work sins I have a hard time to find information on what I am trying to do.
What I am trying to do is to make a game that works similarly like the game Lolo. You push around blocks in 4 directions and so on… So I thought that the best way to do this is to make my own behavior script and apply it to the blocks.
This is the best I have come up whit and it is very bad could any one give some help in this?
What I am trying to do is to make a game that works similarly like the game Lolo. You push around blocks in 4 directions and so on… So I thought that the best way to do this is to make my own behavior script and apply it to the blocks.
This is the best I have come up whit and it is very bad could any one give some help in this?
About the author
Torque Owner Conny Landstedt
if (!isObject(PushedBlockMovementBehavior)) { %template = new BehaviorTemplate(PushedBlockMovementBehavior); %template.friendlyName = "Pushed Block Movement"; %template.behaviorType = "Movement"; %template.description = "Tells a block to move in same direktion that it is being pushed."; %template.addBehaviorField(xVelocity, "The object's horizontal speed", int, 4); %template.addBehaviorField(yVelocity, "The object's vertical speed", int, 4); %template.addBehaviorField(stopingSpeed, "Slowdown", int, 2); } function PushedBlockMovementBehavior::onBehaviorAdd(%this, %modifier, %worldPos) { %this.owner.linearVelocity = %this.xVelocity SPC %this.yVelocity; } function PushedBlockMovementBehavior::onBehaviorAdd(%this, %modifier, %worldPos) { %this.owner.setDamping = %this.stopingSpeed; } function PushedBlockMovementBehavior::onCollision() { if (%collision && %top) { %this.setLinearVelocityY( %this.yVelocity ); } else if (%collision && %bottom) { %this.setLinearVelocityY( -%this.yVelocity ); } else if (%collision && %left) { %this.setLinearVelocityX( %this.xVelocity ); } else if (%collision && %right) { %this.setLinearVelocityX( -%this.xVelocity ); } }