Page 2 of 2

Re: how could i know if it run correctly with linux server no graphic

Posted: Sat Aug 03, 2019 3:52 am
by parapoohda
Thank you norbo.

Re: how could i know if it run correctly with linux server no graphic

Posted: Fri Aug 09, 2019 11:40 am
by parapoohda
My client and server are unsync. It walk with difference velocity. My client is faster. Client use Unity. And Sever is use updateCharacterGoal.
I send bepu target and speed back to client. And then make character move.
But in bepu I make it send position back as foot print.

Here are my thread code

Code: Select all

void PoolThread()
        {
            var deltaTime = 0.015f;
            var sleepTime = (int)(deltaTime * 1000);
            while (true)
            {
                simulation.Timestep(deltaTime, threadDispatcher);
                foreach (var pair in walkCharacters)
                {
                    var character = pair.Value;
                    if (character.CalculateMagnitude() > 0.5)
                    {
                        var distant = character.CalculateDistant();
                        if (distant > 0.2)
                        {

                            if (!character.IsCalculateVelocityYet)
                            {
                                character.CalculateVelocity();
                            }
                            //charac.MunipulateVelocity();
                            character.CharacterInputt.UpdateCharacterGoals(character.Velocity, character.MoveSpeed, [color=#FF4000]sleepTime[/color]);
                            character.InstantMove();
                        }
                        else
                        {
                            walkRemoveCharacters.Add(character.collider.bodyHandle);
                        }
                    }
                }
                foreach (var handle in walkRemoveCharacters)
                {
                    if (walkCharacters.ContainsKey(handle))
                    {
                        walkCharacters.Remove(handle);
                        //simulation.Bodies.Remove(handle);
                        //handleUnits.Remove(handle);
                    }
                }
                walkRemoveCharacters.Clear();
                if (isStop)
                {
                    break;
                }
                Thread.Sleep(sleepTime);
            }
        }
First i use sleep time but it seem slow at UpdateCharacterGoals. After that I try deltatime but it is slower.
So I try this

Code: Select all

void PoolThread()
        {
            while (true)
            {
                foreach (var pair in walkCharacters)
                {
                    var character = pair.Value;
                    if (character.CalculateMagnitude() > 0.5)
                    {
                        var distant = character.CalculateDistant();
                        if (distant > 0.2)
                        {

                            if (!character.IsCalculateVelocityYet)
                            {
                                character.CalculateVelocity();
                            }
                            character.CharacterInputt.UpdateCharacterGoals(character.Velocity, character.MoveSpeed, deltaTime);
                            character.InstantMove();
                        }
                        else
                        {
                            walkRemoveCharacters.Add(character.collider.bodyHandle);
                        }
                    }
                }

                foreach (var handle in walkRemoveCharacters)
                {
                    if (walkCharacters.ContainsKey(handle))
                    {
                        walkCharacters.Remove(handle);
                        //handleUnits.Remove(handle);
                    }
                }
                walkRemoveCharacters.Clear();
                if (isStop)
                {
                    break;
                }
                Simulation.Timestep(deltaTime, threadDispatcher);
            }
        }
Program seem do nothing. I think because of it is rapid fire.

I have another question what is thread dispatcher?

Re: how could i know if it run correctly with linux server no graphic

Posted: Fri Aug 09, 2019 10:35 pm
by Norbo
Thread.Sleep will sleep at least as long as the input value, but is not guaranteed any level of precision beyond that. The resolution depends upon the operating system. On windows, I believe the default resolution is 15.625ms, so you're dealing with very coarse timing. It's possible to force higher resolution, and it's possible to use Thread.Sleep(1) if you know you need to sleep a duration longer than the sleep resolution to help skip some time, but for significant precision you generally need a busy loop. (To make it a little friendlier, you can use Thread.Yield and Thread.Sleep(0) to schedule different sets of waiting threads.)

On top of that, it's not enough to simply wait a fixed delta time between updates, since the update itself could take time. To know how much longer you need to wait, you have to measure how long it's actually been since the start of the last update. Stopwatch.GetTimestamp/Stopwatch.Frequency can give you reasonably precise measurements.
I have another question what is thread dispatcher?
It's the interface that bepuphysics uses to launch threads for multithreading internally. It should launch a number of threads equal to the number of workers you want to use- the engine handles job scheduling internally.

If you don't want to use multithreading internally, you can just not pass a thread dispatcher into the simulation.Timestep function.

Re: how could i know if it run correctly with linux server no graphic

Posted: Sat Aug 10, 2019 4:18 am
by parapoohda
Thank you.
On top of that, it's not enough to simply wait a fixed delta time between updates, since the update itself could take time. To know how much longer you need to wait, you have to measure how long it's actually been since the start of the last update. Stopwatch.GetTimestamp/Stopwatch.Frequency can give you reasonably precise measurements.
You mean i can find fixed time by Stopwatch.GetTimestamp/Stopwatch.Frequency. Is this will get me delta time right?
Or you mean I have to use that every thread frame.(Use it inside thread)

After I make more dt the faster it walk after 6 it walk faster than unity

Code: Select all

 simulation.Timestep(deltaTime, threadDispatcher);
Is this code tell bepu deltatime?
What I have to put in this deltatime?


What is delta time I have to put in update character goals

Re: how could i know if it run correctly with linux server no graphic

Posted: Sat Aug 10, 2019 6:25 pm
by Norbo
Or you mean I have to use that every thread frame.(Use it inside thread)
Yes, in order to wait the correct amount of time, you must constantly be measuring how much longer you have to wait:
measuredwaiting.png
measuredwaiting.png (7.99 KiB) Viewed 20144 times
Is this code tell bepu deltatime?
What I have to put in this deltatime?
The simulation itself should operate on a fixed timestep- choose a constant value ahead of time. After that much time has elapsed (as measured in the waiting loop) since the start of the previous update, you trigger another timestep with that constant timestep duration.

UpdateCharacterGoals needs the same fixed timestep duration.

Re: how could i know if it run correctly with linux server no graphic

Posted: Sun Aug 11, 2019 7:08 am
by parapoohda
Thank you.

Re: how could i know if it run correctly with linux server no graphic

Posted: Wed Sep 04, 2019 8:52 am
by parapoohda
I'm made stand alone version after not understand where I miss. Now this stand alone also use as it is in project. I don't know why it is slow.
Help me please.
Thank you.
:D :D :D

https://github.com/parapoohda/testBepu

I only make it move forward. And It is base on character demo.

Re: how could i know if it run correctly with linux server no graphic

Posted: Thu Sep 05, 2019 1:19 am
by Norbo
The CharacterControllers system itself is not being used, so the only thing active is the CharacterControllerInput air control. The CharacterControllers needs to be hooked up like in the original demos.

Re: how could i know if it run correctly with linux server no graphic

Posted: Thu Sep 05, 2019 2:20 am
by parapoohda
Oh I have to look into it. Thank you.

It seem after use character demo callback it is walkable.
But I want to make online game can All character share same character controller?

Update
I seem i am silly. I think character controller is for one character. But after I share character control It move(I move 2 character with different direction).

Re: how could i know if it run correctly with linux server no graphic

Posted: Thu Sep 05, 2019 6:27 pm
by Norbo
An individual CharacterController is indeed only for a single character and should not be shared, but the CharacterControllers system is designed to handle all the characters in the simulation.

Re: how could i know if it run correctly with linux server no graphic

Posted: Fri Sep 06, 2019 1:44 am
by parapoohda
Thank you. I didn't notice there are character control with and without s.

Re: how could i know if it run correctly with linux server no graphic

Posted: Sat Dec 07, 2019 11:43 am
by parapoohda
It try to use broad phase to tell which unit is near player. So I don't have to send every thing in bufferpool(game map) to client.
but I think broad phase work incorrectly with static.But it work fine with dynamic.
Can I use broadphase to see static object too.
Maybe because I use handle to refer to my custom object. Because first static and first dynamic share same handle (Not sure). So it break.

Is broadphase can sense static?
Is dynamic and static object can share same handle?

thank you :D :D :D

Re: how could i know if it run correctly with linux server no graphic

Posted: Mon Dec 09, 2019 12:00 am
by Norbo
Is broadphase can sense static?
Is dynamic and static object can share same handle?
Yes to both. The broad phase reports CollidableReference instances which have a Mobility property that can be used to distinguish between bodies and statics.

Note that the handle and mobility flag are packed into the CollidableReference.Packed field, so it could serve as a simulation-wide unique collidable identifier if you want.

Re: how could i know if it run correctly with linux server no graphic

Posted: Tue Dec 10, 2019 6:22 am
by parapoohda
Thank you. You're very helpful.