Game Development Community

A couple of questions and problems in TGB concerning sprite animation and camera mounting

by Saku Bielawska · in Torque Game Builder · 04/29/2009 (6:50 pm) · 5 replies

So...
I'm a complete beginner in TorqueScripting, and TGB in general.
I tried just "jumping" in... and... I guess, for a non-programmer, I didn't do too bad, but, I didn't do all that great at all.

I'll start with the situation.
2D Platformer, similar to megaman, mario, etc., but different. Different how? I'm not sure yet.

Anyway, the problems.
I've gotten movement down, basically, and physics work okay on the character, but, for some reason, when I leave them standing still, the resulting sprite is large in comparison to the rest of the sprites (and, more to the point, larger than it is supposed to be), and the idle animation does not play (rather, it stays on that one, enlarged frame).
When jumping, I've managed to get the game to use at least one frame of the jumping animation when the character goes up, but the minute it stops going up, it immediately goes back to the idle stance, or the walking animation (if the player moves the character left or right), instead of going into a transition animation and a falling animation.

Then, there's the camera mounting;
I've mounted a camera onto the character. Honestly, I'm just glad that I was able to figure this out on my own at all, but, the camera is jittery, and causes many headaches. It's not very smooth. Is there a solution to this?

That's about it for now.
Please.
Help.
Me.
*dies, but found a 1-Up prior to entering the forum*

About the author

Recent Threads


#1
05/01/2009 (10:19 am)
Moving this to TGB public forums so you get a quicker response.
#2
05/01/2009 (11:35 am)
Hey man, check out my camera behavior and study the code to how it is done. The camera can be attached to any object, and can be used to follow in the X or Y direction or both at the same time.

When, I was developing the camera I had the same issue as you, and the sprite animation did not look smooth. I was able to solve this issue by after updating the camera position, I then updated the owner to the behavior with the position of the camera.

In another set of files, I have included my platformer movement behavior and one way platform behavior. The platformer movement can walk up slopes and down them, jump, and not show any jittering while standing still on a flat surface. You will need to enable only 2 things on the animated object, one being the Send Collision, and the other being Send Physics. You will also need to at least have 2 required animations for the behavior to work: Walking / running, and Jumping.

On any solid ground objects to collide with all you enable is Receive Collision, and set the object to Immovable in the TGB Editor. Turn off receive physics, and send physics, because they are not need for the walkable ground.

The one way platform behavior can be set to allow the character to enter from the Top, Bottom, Left, or Right. The collision detection is setup automatically when the behavior is applied so there is no need to edit the collision or physics in the TGB editor.

I encourage everyone to download the files and study the scripts behind them.

Enjoy ;]

Here is a link to the files:

www.gfx-null.com/behaviors/platformer_behaviors.zip
#3
05/01/2009 (12:45 pm)
I love you.
#4
05/03/2009 (3:46 pm)
Awesome! Thanks as well.
#5
05/04/2009 (7:30 pm)
Hey guys, I just realized that I accidentally changed something that wasn't supposed to be changed.

in the platformerMovement.cs look in the update_collision function for:

if(%normalX < 0 || %normalX > 0)
{
   %xVelocity = 0;
}

Change it to this to solve an issue with walking up slopes:

if(%normalX <= -1 || %normalX >= 1)
{
   %xVelocity = 0;
}

Sorry about that, I accidentally changed it to 0 when adding the comments. It really should be the -1 and 1. That way the character is only stopped if it hits directly against a flat side wall and not a ramp.