Game Development Community

newbie:how to make player "kick" a puck

by Alex Reuter · in Torque Game Engine · 09/03/2001 (4:56 pm) · 5 replies

Hello List,
I am extremely new to the tools of this trade and am currently trying to make a very basic pong-like game. I was able to make a puck, basically a thin cylinder, in 3dsmax and get it into the example. My level is just a flat plane. Anyway, heres the question:
Does anyone know how I would make the player kick the puck instead of climbing on top of it?

I know this is a very general question, but I have lots of them ;). A small wish list follows.

1. Does the puck have be created specially so it can move about?
2. How would I go about creating a very simple paddle type player?
3. Where would I implement basic physics for the puck?
4. What would be the best tool to use to make the rink itself? I've experimented with WorldCraft but would ideally like the rink to be located outside.
5. What would be the best way to make a goal?
6. Where would I store the score?

As you can see, I have lots of work to do. Any hints or suggestions, pointers, resources, basically anything anyone can think of that might help would be greatly appreciated.

Thanks,
Alex

#1
09/04/2001 (11:16 am)
As for the player not jumping on top of the puck.. you can either make the puck a certain height above the player's step height, or you could lower the player's step height (I think, but im not sure, that the step height is set in the Player's Datablock which is somewhere in the scripting code..)

1. Does the puck have be created specially so it can move about?
Not really, but getting it to move is a different thing altogether :)

2. How would I go about creating a very simple paddle type player?
Same way you made a puck, just make him a rectangular prism ;)

3. Where would I implement basic physics for the puck?
Basic physics are already implemented.. though if you were making a hockey rink or air hockey type thing, you'd probably want to lower the frictional forces (not sure where that's done) so it glides better

5. What would be the best way to make a goal?
Learn up on triggers and make one that would go off whenever the puck entered the goal area

6. Where would I store the score?
Scripts, probably, and have a gui ctrl that displays the score on the HUD (couple ways to do this)

Hardest part would be getting the puck to move and bounce off the sides of the rink I think, have fun :)

-nohbdy
#2
09/05/2001 (9:28 pm)
Thanks for the tips!

You were right on the money with stepHeight. I added this line to player.cs:
maxStepHeight=0.1;
And the player now bumps into the puck.

Regarding:
>>2. How would I go about creating a very simple paddle type player?
>>>Same way you made a puck, just make him a rectangular prism ;)

I made a paddle in 3dsmax and could not get it to work in place of the player.dts file. I changed:
shapeFile = "data/shapes/player/player.dts";
To:
shapeFile = "data/shapes/player/puck.dts";
In player.dts. Wishful thinking I guess. There appears to be alot going on there that I don't grasp.

Regarding:
>>Hardest part would be getting the puck to move and bounce off the sides of the rink I think, have fun :)

I think the resource posted by Tim Gift on throwing v12 items might hold some promise.
I was wondering if through scripting you could give the puck the ability to throw itself? It would somehow check to see if it was colliding with a player or a wall and if so throw itself away. Like a smart-puck. Just an idea.

As long as I'm posting, does anyone know if there is there a general way to have a moving object through scripting? Or move an object through scripting? Like could you make a "walking tree" that moved back and forth along a path?

Anayway, thanks again for all your help nohbdy!
Alex
#3
09/05/2001 (9:31 pm)
i believe the moving of objects is handled by the projectile system, which is not working right now
#4
09/06/2001 (12:02 am)
About your paddle model - can't really help you.. I don't have 3ds unfortunately, so I haven't been able to play with any models, waiting for the MilkShape exporter to mature before I do (by then there should be plenty of information for me to reference too ;) I'm not the best modeler in the world)

As for the puck throwing itself, this would probably be possible, though I don't know how realistic you could make it bounce... with collisions, you'd need to know the angle of incidence(at least I think that's what that angel is called, the angle between the objects velocity vector and the surface's normal) of a collision to determine what direction it needs to go after the collision
\   |   /  -->Object bounces off a wall
 \a |b /   -->angle a = angle b
  \ | /
___\|/___|-- <-wall
The internal code can deal with this (and probably does already), but I don't know how hard it would be to do within the scripting language even if the puck could 'throw itself' so to speak.. (the angle might be passed to the onCollision function or whatever it is you'd use and it'd be a matter of finding the part of the vector perpendicular to the wall, taking the negative of it, then adding that to the parallel part to find your new direction vector...

As for a shape that moves back and forth (especially along a path), I think you'd need AI code which is broken too... a projectile will move but once it has its initial direction and velocity it won't really stop til it hits something and blows up =)

Anyway, I'm probably not the best person to be answering questions like this, since I haven't really tried ever tried to get objects working in-game... but hey, any reply is better than no reply at all =) besides, if I were blatantly wrong, im sure someone would say something about it

-nohbdy
#5
09/06/2001 (12:35 am)
Wouldn't have to throw itself.

You would calculate the vector the puck needs to travel in and then use an applyimpulse or simliar function to move the puck