World Gravity/World rotation question
by NiN-NiN · in Torque 3D Beginner · 07/30/2013 (4:50 am) · 13 replies
Hi everyone
Just curious is it possible to change the gravity in Torque through script where the players world rotates 90 degrees?
If it's not that simple is it possible to group a bunch of objects/3d models together in a group in torque or even a simgroup and rotate them all 90 degrees?
Does anyone have an idea on how the whole world could rotate?
Just curious is it possible to change the gravity in Torque through script where the players world rotates 90 degrees?
If it's not that simple is it possible to group a bunch of objects/3d models together in a group in torque or even a simgroup and rotate them all 90 degrees?
Does anyone have an idea on how the whole world could rotate?
#2
07/30/2013 (6:30 am)
Well, of course it's possible.... Just don't know how simple it would be. In theory we should be able to adjust the gravity vector but in reality I don't know if this is actually exposed in any way to the user. I'll try to answer this one shortly - have to get ready for work....
#3
Honestly if someone could point me in the right direction or even some code to rotate a object 90 degrees in script on either axis that would help.
I'm essentially going to have the player inside a cube (And a few objects as well) and want to be able to have a keybind that keeps rotating the cube 90 degrees on one axis and another keybind for the other axis so it looks like the world is moving so the user was standing on the floor and has all of a sudden slid to the wall or something like that :)
07/30/2013 (7:36 pm)
Thanks Richard that would be great if you can have a look at it :)Honestly if someone could point me in the right direction or even some code to rotate a object 90 degrees in script on either axis that would help.
I'm essentially going to have the player inside a cube (And a few objects as well) and want to be able to have a keybind that keeps rotating the cube 90 degrees on one axis and another keybind for the other axis so it looks like the world is moving so the user was standing on the floor and has all of a sudden slid to the wall or something like that :)
#4
I searched for: "rotate object in script" in the forums.
07/30/2013 (7:54 pm)
www.garagegames.com/community/forums/viewthread/104031I searched for: "rotate object in script" in the forums.
#5
07/30/2013 (10:58 pm)
Wait, wait - duh! Physical Zones! Look into that....
#6
I looked into physical Zones last night but all I could do was float/shoot the player model up or down really there wasn't much I could do.
I didn't try rotating the actual physical zone but if i do that wouldn't the player just be stuck against a wall instead of walking on the wall?
07/30/2013 (11:06 pm)
Hi RichardI looked into physical Zones last night but all I could do was float/shoot the player model up or down really there wasn't much I could do.
I didn't try rotating the actual physical zone but if i do that wouldn't the player just be stuck against a wall instead of walking on the wall?
#7
- the gravity force is hardcoded in the player class therefore you have to touch the c++ side to adjust the forces or use a special case for gravity mod at least.
- rotating in script would skip the client side interpolation at all and your rotation will not be smooth.
07/31/2013 (7:45 am)
You cannot do it in script for 2 reasons:- the gravity force is hardcoded in the player class therefore you have to touch the c++ side to adjust the forces or use a special case for gravity mod at least.
- rotating in script would skip the client side interpolation at all and your rotation will not be smooth.
#8
In terms of other objects, I'm pretty sure things like RigidShapes and Items will, when they stop moving naturally, set some sort of internal flag that prevents them from moving until disturbed. So if you changed the gravity vector, they wouldn't immediately start moving again anyway.
I think a good start would be to start using a proper physics library (Bullet or PhysX) which may do a better job of handling stuff like collisions and changing gravity.
07/31/2013 (10:31 pm)
In addition, the Player class is hardcoded to always point upwards (the world z axis). It's no a trivial job to rectify that alone. Your best bet it to rotate the rest of the environment around the player, but as Ivan points out, without hacking into the engine code, the rotation will not appear smooth.In terms of other objects, I'm pretty sure things like RigidShapes and Items will, when they stop moving naturally, set some sort of internal flag that prevents them from moving until disturbed. So if you changed the gravity vector, they wouldn't immediately start moving again anyway.
I think a good start would be to start using a proper physics library (Bullet or PhysX) which may do a better job of handling stuff like collisions and changing gravity.
#9
07/31/2013 (10:37 pm)
Years ago I was looking into an avatar that could climb over stuff so up was not always up on the camera. It was suggested to me to use the vehicle class to create an avatar that could be at any angle.
#11
I have worked out a way to do it what i need which is create two separate rooms that are rotated different ways and to make it look like the world has rotated.
But I do seem to have a new problem cause to do that I need to teleport to the other location.
I had a look at documentation and couldn't find this function available to use besides one in the SFX section.
Was get and setTrasnform renamed?
08/01/2013 (4:43 am)
Thanks guys for this I've looked at it all and I think it's a tad over my head sadly.I have worked out a way to do it what i need which is create two separate rooms that are rotated different ways and to make it look like the world has rotated.
But I do seem to have a new problem cause to do that I need to teleport to the other location.
function serverCmdTeleportPlayer()
{
%xfrm = defaultplayerdata.getTransform();
%x = getWord(%xfrm, 0) + 400;
%y = getWord(%xfrm, 1) + 1;
%finalPos = %x SPC %y SPC %z;
defaultplayerdata.setTransform(%finalPos);
}I used the above script from the forums but it doesn't work it says getTransform and setTransform don't exists.I had a look at documentation and couldn't find this function available to use besides one in the SFX section.
Was get and setTrasnform renamed?
#12
08/01/2013 (4:59 am)
defaultplayerdata is a datablock, not the actual player object. Is this a multiplayer game? If it is a multiplayer game you need to go through the list of active players and adjust the ones that need adjusted. You may be able to do that with zone events or something similar. For single player you can take some shortcuts, but if you go multiplayer later you will have to "do it right" anyway.
#13
http://docs.garagegames.com/torque-3d/official/index.html?content/documentation/Scripting/Overview/Introduction.html
So that has now fixed it for me :)
Thank you all for your help
08/01/2013 (5:30 am)
This will be a single player for now but I have got teleporting to work now i couldn't find anything but old threads using the search on garagegames but my fiancee googled and came across thishttp://docs.garagegames.com/torque-3d/official/index.html?content/documentation/Scripting/Overview/Introduction.html
So that has now fixed it for me :)
Thank you all for your help
Ahsan Muzaheed
Default Studio Name
u can select them form world editor and rotate.
but in case of hudreads of objects it is possible by iterating through all childs of the simobject and rotate each of them at X degree from script
problem is if a simobject contains another sim object,into that another one.in that case u will have to recursively get the child objects.
try to get all childs as a tab seperated string.the do the opertaion.