Game Development Community

Need some serious scripting help...

by Mark Grooby · in Torque Game Builder · 06/25/2006 (7:18 am) · 5 replies

Alright, I've had TGB for about 3 days, so I'm still pretty pathetic at TorqueScript.
I am making a platformer game, and I can't seem to script my character to move.
So far I have completed the fish tutorial, the RTS tutorial, and the Whack a Mole tutorial,
so I do know a bit of TorqueScript. I tried the Platformer tutorial, except it seemed that
half the tutorial wasn't really there, as it told me to do things like: "Put this script into
actionCommands.cs" except it had not previously told me to create that .cs file. Also, it
kept telling me to add things to a certain function, even though I had not been told to
create that function. Therefore I cannot create a game of my favourite genre, 2d platformer.
Would somebody please be kind enough to post some simple movement and jumping script?
This would not need to handle walking up or down ramps.

Also, does anybody have or could make a quick static sprite, that doesnt really need
to be animated while moving. I am currently using a red ball, but does anybody have
any better ideas? If you do, please post. Thanks in advance.

-Mark Grooby

P.S. I know I'm asking a huge amount of help, but I would really appreciate it if someone
could get me started with TGB, as I'm obviously not very good yet.

#1
06/25/2006 (7:44 am)
First off, you should check out the fish game tutorial (different from the fish demo tutorial) which goes over basic key input and movement. Once you get comfortable with that, there are several ways to get the control you want out of your character. One way would be to set up your control object (your player-controlled character) to collide with your environment and then set a constant force on him/her/it in the positive Y (which is down). You can set the collision settings in the collision rollout on the edit tab and you can set the constant force on the physics rollout in the edit tab. A good starting point is about 120 in the Constant Force Y field with the "gravitic" checkbox checked (which makes the force independednt of mass, as the force from gravity should be). With just that set and your left/right movement keys, your character should be able to walk along whatever environment you set up, including ramps and stuff, as long as your collision is set up right. For collision you're probably gonna want to set POLYGON detection and CLAMP response on both your environment and your character. By default, POLYGON uses the bounding box of an object, which makes it really convinient for placing rectangular objects in the environment. Once you have that working, its a simple task to add a jump. All you need to do is bind your jump key to a function that adds an impulse force to the control object in the negative Y direction with maybe a check to see if the character meets some jump conditions (i.e. are they on the ground / do they have enough energy / whatever).

As for the static sprite, you could just pop open MS Paint and draw a quick mock-up of what you want and load it into your project if theres nothing included with TGB that suits your taste and you dont have any other art software at your disposal.
#2
06/25/2006 (8:56 am)
You can use the Mannequin Man sprites that I created for the platform tutorial. Just chop out one or two that you want you use and presto - static man shaped sprite.

You should also ask for scripting help in the private forums.
#3
06/25/2006 (6:24 pm)
I tried using the scripting from the fish game tutorial and modifying it a little, but it didn't work. I set my characters class to player, and set the constant Y force to 100. Would somebody be able to post what their player.cs would look like? (Without ramps or powerups or dying, just movement and jumping)

-Mark Grooby
#4
06/26/2006 (11:12 pm)
Woah... would somebody mind answering me? This is getting boring...

-Mark Grooby
#5
06/27/2006 (12:11 am)
Do you want to post in the private forums where someone can answer you? Noone is going to break the EULA and post TGB script in the public forums.