Scripting Moderators ds1-e Posted February 19, 2019 Scripting Moderators Share Posted February 19, 2019 Hi. As title says how i can do bounce player or player + his car backward when player hitcolshape? So i can avoid him to go through colshape. Link to comment
Moderators IIYAMA Posted February 19, 2019 Moderators Share Posted February 19, 2019 The easiest way would be invert it's velocity. But in some cases it might not be very accurate. (In case of a player you have to lift him up a little bit) getElementVelocity setElementVelocity ----- Another way would be resetting the player back to it's previous position. (This might require some more performance impact as you will have to record it's previous position at all times.) ----- Another way would be: calculate from the position of the vehicle/player and the position colshape the difference. - Based on each separated axis: x1 - x2, y1 - y2, z1 - z2 (vector) - Based on all axis. (Distance) [might not be required] In case of a sphere colshape the distance from the center is always the same. So you do know how much distance is required to move somebody out of the sphere. If you normalize the vector and multiply it by the required distance, what kind of result do you think that will have? (Just becareful not place the player in the ground....) --- The last way. Just teleport him to a known location out of the area. 1 Link to comment
ShayF2 Posted February 19, 2019 Share Posted February 19, 2019 player.position = player.matrix:transformPosition(0, -4, 0) -- this is oop 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