Rotating Platform
by Craig Fortune · in TGB Platformer Kit · 07/15/2008 (4:38 pm) · 2 replies
In reference to thread: www.garagegames.com/mg/forums/result.thread.php?qt=71517 (I started this thread as its about PSK related matters)
I had a brief look at what would be needed to get a rotating platform (like a swing) working earlier.
I've only had the PSK for a couple of days now so I'm obviously not completely clued in with everything it has to offer yet.
I saw a function called getSurfaceImage(%this) which appears to effectively build up a profile of the individual surfaces that a platform can have and store them, then you can do all sorts of nice stuff regarding player (Actor) interaction with it. The issue here in regards to a rotating platform is that as soon as the platform is rotated this data becomes obsolete. A rotating platform will be changing its "ground surface" constantly and as such you'd need to be calling this function (getSurfaceImage) constantly to have the surfaced updated. Not a good idea.
This has sort of put a stop on furthering anything with rotating platforms until a decent solution can be found. I thought maybe iterating over the surfaces and just doing the rotation multiplication on them could be a good solution as the surfaces themselves aren't changing shape, just angle. I'm still hesitant on a performance aspect however.
Any thoughts?
edit: links
I had a brief look at what would be needed to get a rotating platform (like a swing) working earlier.
I've only had the PSK for a couple of days now so I'm obviously not completely clued in with everything it has to offer yet.
I saw a function called getSurfaceImage(%this) which appears to effectively build up a profile of the individual surfaces that a platform can have and store them, then you can do all sorts of nice stuff regarding player (Actor) interaction with it. The issue here in regards to a rotating platform is that as soon as the platform is rotated this data becomes obsolete. A rotating platform will be changing its "ground surface" constantly and as such you'd need to be calling this function (getSurfaceImage) constantly to have the surfaced updated. Not a good idea.
This has sort of put a stop on furthering anything with rotating platforms until a decent solution can be found. I thought maybe iterating over the surfaces and just doing the rotation multiplication on them could be a good solution as the surfaces themselves aren't changing shape, just angle. I'm still hesitant on a performance aspect however.
Any thoughts?
edit: links
#2
Yes thats pretty much what I was thinking, hence my "Not a good idea" comment.
In regards to your comments about rotating the surface image that isn't what I meant however. I was thinking of a solution more like rotating the points of the surfaces around an origin point (which would be the rotation point of the whole object) thus giving you correct surface points and normals. However this wouldn't really save much time in the long run anyway as its still a fair chunk of work to do on a per update basis. :S
07/15/2008 (5:08 pm)
Phillip,Yes thats pretty much what I was thinking, hence my "Not a good idea" comment.
In regards to your comments about rotating the surface image that isn't what I meant however. I was thinking of a solution more like rotating the points of the surfaces around an origin point (which would be the rotation point of the whole object) thus giving you correct surface points and normals. However this wouldn't really save much time in the long run anyway as its still a fair chunk of work to do on a per update basis. :S
Associate Phillip O'Shea
Violent Tulip
For starters, Torque Script is slow. If you generate the surface image upon loading and then leave it alone, everything is fine, no trouble at all. If you wanted to constantly update the surface image, then you start to get huge performance issues. You could, however, remove the "surface image" idea all together and process the whole polygon on each platform when the actor passes it, but the "surface image" idea was introduced to limit the amount of information that was processed each frame.
The next problem is what rotation actually does to the surface of a platform.
Lets say you have a rectangular platform without rotation. It's surface is just the flat segment at it's top. Let us rotate this object by 45 degrees. It now as two exposed surfaces forming a peak. Upon rotation, the whole "surface image" process needs to be conducted again. This is why you cannot just apply a rotation to the surface image.
The most simple method would be to create a "Rotating Platform" behavior and just update the surface image upon rotation, not the "best" solution, but a simple one.