Game Development Community

Need help with elastic grapple hook

by Oswaldo Grassiotto · in Torque Game Engine Advanced · 02/02/2009 (3:46 pm) · 4 replies

I'm new to torque and am playing around with the source in order to learn. I implemented the grapple hook described in this thread:

http://www.garagegames.com/community/forums/viewthread/76000

It works but movement is jerky, I changed the code to make it behave like an elastic rather than hard rope but the jerky movement is now the problem. I've debugged the updateMove code and found why its jerky but have no idea how to fix it.
Basically I noticed that the value of "this" (Player * const) keeps alternating between two different ones at each consecutive iteration of the updateMove function. When I get one of them the public variable (belonging to the Player class) "mGrappleID" holds the true id of the grapple hook I launched, then the next time updateMove is executed "mGrappleID" is 1 (and player object is different), so it won't locate the hook with "Sim::findObject" and no grapple force is applied. Then next time updateMove is executed I get the first player object again and forces are applied properly, its almost as if there are two player objects for the same person.

#1
02/02/2009 (4:42 pm)
Remember that even in a single player game, there is both a client and a server, and the reason for values alternating like that is that the function is being called alternately on both the server and the client. Pointers and object IDs are not shared between the two.
#2
02/02/2009 (5:04 pm)
Thanks for the quick reply, I thought about that but wasn't really sure if it was the cause. Any suggestions as to how to solve this problem? Somehow send the values to the client object(if thats even possible)?
#3
02/02/2009 (6:06 pm)
Yes, that's the usual solution. See this bit in the docs:
docs.garagegames.com/tgea/official/content/documentation/Engine%20Overview/Engin...
It may not completely enlighten you, but it should give you some good search terms. It is a commonly discussed topic, so you should find something useful.
#4
02/02/2009 (7:38 pm)
Aha that's it, ghosting. Thanks just what I needed :). I'll post the code for the hook as soon as its finished since I couldn't find any fully functional grapple hook for tgea using the search.