Page 1 of 1

Unmount issue

Posted: Thu Dec 05, 2019 5:42 pm
by Hodo33
My player needs rest so I provided a bed. Interact with bed, you get mounted in sitting pose and pops a dialog to get up.
When you click the get up button it calls this:

function serverCmdDoneBed(%client)
{
%client.player.bedrep = 0;
%client.player.unmount();
%bed = %client.player.bed;
%client.player.bed = 0;
%spawn = "bedSpawn"@%bed;
%client.player.setTransform(%spawn.getTransform());
%client.player.isMounted = false;
}

I have a player spawn point called bedspawn1,2,3 etc all is well at this point.
If the player sits on the bed again and gets up, they fall through the floor. Can be repeated and the spawn point is way above the floor.
I have this same issue with a vehicle if I get in then out then in and back out I fall through the land.
It's almost like the engine loses track of position or collision is lagging a update or it's not cleared. Been looking in the engine but can't see where it happens.
anyone encounter this issue ?

Re: Unmount issue

Posted: Sat Dec 07, 2019 12:37 pm
by Duion
Why do you respawn the player out of the bed anyway? Is it not enough to just change the mount and animation?

For spawning you should always spawn things above to where you want them spawned, so you have a little buffer zone that prevents glitching through the floor, if you already have that the problem may be somewhere else.

Also it may depend on the physics engine you use, I had problems with PhysX and Bullet before. For example one issue was that when I fire my weapon and run forward, the player somehow managed to run faster than the bullet and the bullet would hit him, causing damage to yourself.

But I can just guess here, a video or so would probably help much, to me it just sounds you are doing things too complicated. I mean if you really want to respawn the player near the bed, then you can manually place a spawn that works I don't see the problem there. Maybe the animation messes up the collision box and that is why you glitch through.

Re: Unmount issue

Posted: Sat Dec 07, 2019 11:32 pm
by Bloodknight
When you say 'way above the floor' could you quantify that? also, you should be able to just set an actual position and teleport the player without a spawn point, as long as you have a small clearance above the floor object. Is the effect occurring *during* the animation at a particular spot? or before or after?

Re: Unmount issue

Posted: Mon Dec 09, 2019 1:35 am
by Hodo33
Using basic physics. As I said it works once but if I mount back to the bed without moving and get up again player falls through. I am using a spawnsphere with one meter size. the bottom point of the hedron is like 0.1 m above the floor. If I just do a unmount the player is standing in the middle of the bed so I needed to move him away.
How do I post a direct image here? I.E. no url

Re: Unmount issue

Posted: Mon Dec 09, 2019 2:44 am
by Duion
Uh do you use the default spawn function where it spawns you in a random location inside the spawn sphere? Either change the function or much easier just change the spawn sphere size to something very small, so there is less variation. The polyhedron is just a model to symbolize the spawn sphere, the green sphere is what defines where the player spawns.

I have not thought about the problem of the player standing in the middle of the bed, if you just unmount. Can't think of a good solution right out of my head now for that, maybe one thing, did you know you can make animations offset from the models origin? So you can make an animation where the player goes to bed, without actually changing the players location. At least I think that's possible. Similar to the death animation where the player falls over, but the models origin is still where his feet were before he fell, so you can make a go to bed animation similar like that.

Re: Unmount issue

Posted: Mon Dec 09, 2019 4:02 am
by Bloodknight
you could post as an attachment, but there are good sites for images, Imgur and vgy.me Imgur allows anon uploads, vgy.me needs an account but its free and you can set up albums, also as a bonus both of these sites integrate with sharex https://getsharex.com/

Re: Unmount issue

Posted: Tue Dec 10, 2019 12:20 am
by TorqueFan
Just from memory, I recall the engine does a lot of things along the lines of...

obj->disableCollision();
… do stuff....
obj->enableCollision();

...when certain checks are made. IIRC, you can look at the collision code in 'Item' to see an example of this. I remember trying to get some immediate updates on collision before, and what ultimately nailed it down for me was calling updateWorkingCollisionSet() on the Player object. I believe I even went so far as to make an EngineMethod out of it and calling it from script when I had to.

Re: Unmount issue

Posted: Tue Dec 10, 2019 9:18 pm
by Hodo33
@
User avatar
TorqueFan
you had the magic answer. I did the same and made a engineMethod and call it just before setting the transform and it works perfect.. thanks mucho !!!

Re: Unmount issue

Posted: Thu Dec 12, 2019 2:44 am
by TorqueFan
You're welcome! Glad to see you got it working!