XetaQuake Posted October 8, 2008 Share Posted October 8, 2008 Hey all When i move an object with moveObject and i stand on the object, I'm going with them - thats good. But when the object rotating his z-axis, the player (I'm) don´t rotate with it ;( Is there any possible to prevent that the player just slide on the object, when it's rotating his z-axis? Link to comment
Ace_Gambit Posted October 8, 2008 Share Posted October 8, 2008 Glue yourself to the object? Link to comment
XetaQuake Posted October 8, 2008 Author Share Posted October 8, 2008 The Problem: thats exactly what i don´t want, the player should be free in movement during the objects moves and rotates Link to comment
XetaQuake Posted October 9, 2008 Author Share Posted October 9, 2008 Can anyone help me pleas? I have a Idea, possible it works when i get the rotation of the object and add it to the player. But the Problem is that such a function can´t launches so many times...and stuff like "OnClientRender" are also not a perfect solution - also its Client-Side. Any ideas? Link to comment
DiSaMe Posted October 9, 2008 Share Posted October 9, 2008 Maybe your idea is good. And why couldn't you use it on every frame? That shouldn't be very difficult. You only need to get contact element with getPlayerContactElement, then check its rotation changes and add the value to the player's rotation. Link to comment
Gamesnert Posted October 9, 2008 Share Posted October 9, 2008 Maybe your idea is good. And why couldn't you use it on every frame? That shouldn't be very difficult. You only need to get contact element with getPlayerContactElement, then check its rotation changes and add the value to the player's rotation. Why couldn't you use it on every frame... Ehm... onClientRender IS every frame? Link to comment
XetaQuake Posted October 9, 2008 Author Share Posted October 9, 2008 Yea but onClientRender is Client Side. And the Object that moves are Server-Side. I am not able to make a bright between it I understand Client side, i understand Server side - but not to use it together Link to comment
Gamesnert Posted October 9, 2008 Share Posted October 9, 2008 Yea but onClientRender is Client Side. And the Object that moves are Server-Side.I am not able to make a bright between it I understand Client side, i understand Server side - but not to use it together I think that's one of the most difficult parts of scripting for MTA to be honest. It's not always that easy as triggerServerEvent or triggerClientEvent and you done... =/ Anyway, you got a point there... setTimer(lolz,50,1,...) then? Link to comment
DiSaMe Posted October 9, 2008 Share Posted October 9, 2008 Yea but onClientRender is Client Side. And the Object that moves are Server-Side.I am not able to make a bright between it I understand Client side, i understand Server side - but not to use it together There would be a problem if you needed to rotate a client-side object with server-side script. What does stop you from getting contact element and rotation? Link to comment
XetaQuake Posted October 9, 2008 Author Share Posted October 9, 2008 setTimer(lolz,50,1,...) then? Are you crazy That should not so healthy for a Server moreover, 50 miliseconds are to slow to let it works smoothly Also i am not sure that´s the idea to rotate the player works, BECAUSE: The object is long, so, when it rotates and you stand on the end, you fall down. Now, when you just rotate the player, the player rotates around his own axis - and he still fall down. Link to comment
Gamesnert Posted October 9, 2008 Share Posted October 9, 2008 setTimer(lolz,50,1,...) then? Are you crazy That should not so healthy for a Server Lol did you look at the function name? It's called "lolz", you think I did that for nothing? Anyway, why is 50ms too laggy? I mean, sure framerate is shorter. But still 50ms gets executed bout 20 times... For as far as I know, the average person averagly sees 25 FPS. What would be wrong with the time? 5 frames delay in a full sec... By the way, can't you just use no rotation at all? They can use their gun and RP the rotation? ^^ Link to comment
DiSaMe Posted October 9, 2008 Share Posted October 9, 2008 Also i am not sure that´s the idea to rotate the player works, BECAUSE:The object is long, so, when it rotates and you stand on the end, you fall down. Now, when you just rotate the player, the player rotates around his own axis - and he still fall down. Maybe it's better to get offset of player position from object, when object rotates, get the position with that offset and move player to that position. Link to comment
Ace_Gambit Posted October 9, 2008 Share Posted October 9, 2008 The big question is, how are you planning to make players freely walk around while remaining on the moving object? Link to comment
darkdreamingdan Posted October 10, 2008 Share Posted October 10, 2008 Just because the object is serverside does not mean you can't do it clientside!!! You dont need to overcomplicate things with triggerClientEvent or triggerServerEvent. This is one way you could easily do it: local localPlayer = getLocalPlayer() local root = getRootElement() addEventHandler("onClientRender",root, function() local contactElement = getPlayerContactElement(localPlayer) if contactElement and getElementData(contactElement,"moving") and getElementType(contactElement) == "object" then local a,a,z = getObjectRotation(contactElement) setPlayerRotation ( localPlayer, z ) end end ) Then serverside: moveObject (whatever,124,12561,163) setElementData(whatever,"moving",true) --When its finished moving setElementData(whatever,"moving",false) Link to comment
Gamesnert Posted October 10, 2008 Share Posted October 10, 2008 I don't think he wants to exactly rotate with the object... If you're getting on top of it at a direction of 90, and the object rotates, you'll stand in exactly the objects rotation... So in fact, it's true that you can do some things client-side, but you still have some problems... And is that synched? Link to comment
darkdreamingdan Posted October 10, 2008 Share Posted October 10, 2008 I don't think he wants to exactly rotate with the object... If you're getting on top of it at a direction of 90, and the object rotates, you'll stand in exactly the objects rotation... So in fact, it's true that you can do some things client-side, but you still have some problems... And is that synched? Just offset the rotation then, or measure the changed rotation each frame and increment by that. Link to comment
XetaQuake Posted October 10, 2008 Author Share Posted October 10, 2008 Hey guys First: thanks for all the replays I tested Talidans great script. Here is a movie, pleas look it, so you understand the last problems. There are, as Gamesnert and Talidan already discuss it, two Problems. First: you are not able to run freely, because the rotation gets updated every time. Second: You rotate around your own axis, so you still fall down (see movie) I think its needed to set the rotation relatively to the object or so, but i don´t know how its possible to get a axis from an rotating object Any ideas? PS: I think Talidan has mentioned this problem in his last post, right? Link to comment
DiSaMe Posted October 11, 2008 Share Posted October 11, 2008 I already wrote how to make player rotate around object axis, however, I'm not good at trigonometry. Link to comment
Ace_Gambit Posted October 11, 2008 Share Posted October 11, 2008 Trigonometry is not the problem. You can solve this problem with maths (calculating the right position and rotation that is). What you can't solve is the fact that you can't move when you update the players' position every frame. I am not trying to demoralize anyone, but I personally think it can't be done with the current GTA or MTA physics. But feel free to prove me wrong. Link to comment
Gamesnert Posted October 11, 2008 Share Posted October 11, 2008 Unfortunately, there is no such even as "onElementMove" or "onElementRotate" or something... Neither are client-side versions, so we need to build it round the object stuff. Maybe you can do a table which you index with elements. So if you're standing on a box, it should have the index of the element you're standing on. Then you should save the object's current rotation with "getObjectRotation" and see if it has changed. If so, how much it has changed. Then, you should use "setPlayerRotation" and "getPlayerRotation" to set&get the rotation. (ofcourse setting the player rotation as the current rotation+object rotation) Hope that helps? @Ace_Gambit: Then you can try to do it every 2 frames? It might indeed be a bit dangerous for moving... But well, we can better test&try than just sit, wait and keep thinking if that's true... =/ Link to comment
Ace_Gambit Posted October 11, 2008 Share Posted October 11, 2008 I wouldn't use the setElementPosition function at all. Instead calculate the new position, rotate the player towards that position and make it walk to that position (DP3). That way the player is not blocked in its movement. Link to comment
darkdreamingdan Posted October 11, 2008 Share Posted October 11, 2008 Try this: local localPlayer = getLocalPlayer() local lastRotation local root = getRootElement() addEventHandler("onClientRender",root, function() local contactElement = getPlayerContactElement(localPlayer) if contactElement and getElementData(contactElement,"moving") and getElementType(contactElement) == "object" then local a,a,z = getObjectRotation(contactElement) lastRotation = lastRotation or z local difference = z - lastRotation setPlayerRotation ( localPlayer, getPlayerRotation(localPlayer) + z ) else lastRotation = nil end end ) You might have to add checks for aiming players Link to comment
DiSaMe Posted October 11, 2008 Share Posted October 11, 2008 What you can't solve is the fact that you can't move when you update the players' position every frame. Oh, now I understand that. Maybe we need a function that could put players into positions without interrupting other actions? Link to comment
XetaQuake Posted October 13, 2008 Author Share Posted October 13, 2008 Hey all. Thanks for all the Replays =) Talidan, i tries your new and nice code, but i get a WARNING and so it doesn´t works. Here a the Debugscript 3 warning message: WARNING: transport_c.lua: Bad 'rotation' pointer @ 'setPlayerRotation'(2) - Line 12 This is Line 12: setPlayerRotation ( localPlayer, getPlayerRotation(localPlayer) + z ) Now the strange thing: why it doesn´t work? "localPlayer" should be correctly: local localPlayer = getLocalPlayer() Any ideas? Link to comment
Gamesnert Posted October 13, 2008 Share Posted October 13, 2008 Hmmm... Might it be that you were in a vehicle when the warning occurred? Since if you are in a vehicle, getPlayerRotation returns false. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now