Adds highly customizable gravity modifications to the server.
#[v1.1.0 Lab API] Custom Gravity
1 messages · Page 1 of 1 (latest)

- In this week i will add class specific default gravity probably.

this do not affect pickup
sadly
nor ragdoll too
I was planning to add those this week, i just published it now because ,me being dumb i have created a .NET project instead of .NET Framework and tried to debug all my code. I felt so dumb at the end lol
And it was getting late for me. I published this because it is working rn for players really good
Also ragdoll would need client change
Yeah pickup positions are server sided butt currently i wasnt sure if i can change ragdoll gravity because of that
for pickups i thought about disabling the gravity of the rigidbody and adding constant force component or just some custom script idk
Time to lobby Northwood to let us change client variables!!
Lobby timer is server side
Naturally
Yeah, but that's not gonna change the unity physics :3
We can actually, items like pickups are server authorized. And their positions gets synced with players.
If you change their server positions.
Vola
Currently adding very customizable item gravity vectors
Does these actually work?
Yeah, why would i do it if its not going to work
Plugin currently has the gravity modifier for players, but im currently developing the gravity modifier for items too
I though it would move the item back and forth on client
i just tested it in my local server
it worked
epic
Might add that as a base labapi property too then
Yeah that would be good. Letme send my code
// Makes us able to Set a Pickups gravity easily.
public static void SetPickupGravity(Pickup pickup, Vector3 gravity)
{
// Check if Rigidbody exists.
if (pickup.GameObject.TryGetComponent<Rigidbody>(out Rigidbody rigidbody))
{
// Disable the default Rigidbody gravity so we can add our own one.
// We are doing this because we dont want to change the whole games Gravity value.
pickup.GameObject.GetComponent<Rigidbody>().useGravity = false;
// Add a Constant Force component to simulate our own force
pickup.GameObject.AddComponent<ConstantForce>().force = gravity;
}
}
it just tried and gets the rigidbody
disables gravity
and adds a constant force component

why do you get the component twice
silly
first i added the
getcomponent
and i thought
what if its null
and added the tryget
and forgor the getcomponent
Very cool anyways
thanksie
Next i will figure out how i can modify ragdolls gravity
if its possible
I dont think you will be able to do that
They are client sided
I mean their physics
yeah ragdolls are better client sided
imagine server authorizing every limb
im making every ragdoll client sided in my game too
Ill add synced property then
they are going to be even more desynced on clients than before oh god
lolllll
i hate online game development but i love it at the same time
// Makes us able to remove the pickups force component and enable the default rigidbody gravity.
public static void RemovePickupGravity(Pickup pickup)
{
// Check if Rigidbody exists.
if (pickup.GameObject.TryGetComponent<Rigidbody>(out Rigidbody rigidbody))
{
// Enable the rigidbody gravity.
rigidbody.useGravity = true;
// Check if the Constant Force component exists.
if (pickup.GameObject.TryGetComponent<ConstantForce>(out ConstantForce constantForce))
{
// Destroy the Constant Force component. Atomize it...
GameObject.Destroy(constantForce);
}
}
}
and this is the function to remove it
in case*
makes sense
just reverse
Pickup is affected by default geavity
Physics.Gravity or something like that
Oh right I could just sync the default gravity lol
yeah all rigidbody components effected by it
We are having 0G gaming with this one
im using ChangedRole event for players and for some reason. For gravity to be applied i should delay the gravity set for 0.2 seconds
Timing.CallDelayed(0.2f, () =>
{
ev.Player.Gravity = gravity;
});
I think that is because the role changed event is fired before the actual role update is sent to the client
For some reason its being sent the next frame?
But you send the gravity message before
And it just gets discarded to not cause any exceptions
Ill look at this eventually
I think just moving the event should do the job
yeah there is ChangingRole event i know that it fires before the change of the role that why i used the ChangedRole but it still needed some magic to work
Yeah in short ill fix it
It is working nearly flawlessly but one thing i noticed. Thrown items are lagging because of the server and client position difference. But when item hits something, it gets synced.

the waiting for players timer?
nvm I misread it as client side for some reason and was going to say that it's not
Lol
[v1.1.0 Lab API] Custom Gravity
I am currently thinking of setting gravity for spesific classes
but i dont know if it will be useful

Yo! Just wanted to post that this plugin posts errors on the 14.1 release, but seems to function fine.
at LabApi.Events.EventManager.InvokeEvent[TEventArgs] (LabApi.Events.LabEventHandler`1[TEventArgs] eventHandler, TEventArgs args) [0x0001d] in <bea7f403b90e4786abd99fa819db9853>:0
same here
Yeah changed event seems like is changed or its name changed. Itll be fixed today.
Thanks for sharing


oh i completely forggor, will do it dont worry