Search Unity

[RELEASED] Rival - DOTS Character Controller

Discussion in 'Assets and Asset Store' started by PhilSA, May 31, 2021.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926


    Rival is a DOTS character controller built for extensibility & performance, and made with networking in mind. It comes with a samples project that includes a 3D Platformer and a fully-functional Online FPS built with DOTS NetCode!

    IMPORTANT: This asset will only work in DOTS projects. It cannot be added to regular Monobehaviour/GameObject Unity projects

    [ Store Page ]
    [ Documentation Website ]
     
    Last edited: Sep 19, 2022
  2. JJ-Jabb

    JJ-Jabb

    Joined:
    Feb 6, 2015
    Posts:
    42
    Been waiting for this!
    Quick question, when you say this:
    • The Hybrid Renderer package is required for rendering in DOTS
    I assume this isn't an actual hard requirement of Rival and it would be possible to use something like GPU Instancer for rendering instead - am I correct?
     
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Yes that's correct, I mostly wrote the above message for people who aren't really familiar with DOTS, but Rival doesn't depend on the HybridRenderer in any way.

    Your approach should be fine
     
    Last edited: Jun 1, 2021
    andreiagmu likes this.
  4. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    @PhilSA Hi, I tested the Rival samples, after I installed them (following the "Samples - How to Install" tutorial) most of them worked perfectly. :D

    The only issue I had was in the Basic Sample, the Player character wasn't being spawned, and Unity complained of a missing entity during game initialization (more specifically, in BasicSceneInitializationSystem.cs, line 84).

    Turns out the sceneInitializer.CharacterSpawnPointEntity wasn't correctly set up in the Main subscene. So, I just opened the Main subscene, selected the SceneInitialization gameobject, and in the BasicSceneInitializationAuthoring component, I assigned the SpawnPoint gameobject to the "Character Spawn Point Entity" field (this reference was missing after I imported the samples, and even after a full Library Reimport, it was still missing).

    After I set up that reference in the inspector, then the character spawned correctly. :)

    capture_20210601_190008_001.png
     
    varnon and PhilSA like this.
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Thank you! Another user mentioned that to me earlier as well, and v0.2 is on the way with a fix. Also contains a fix for compilation errors due to an unrecognized character in the code
     
    andreiagmu likes this.
  6. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Hi @PhilSA. How's the performance on mobile platform with DOTS NetCode?
     
  7. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I haven't gotten around to building for mobile, but I'll see if I can do a test soon
     
    optimise likes this.
  8. Lontis

    Lontis

    Joined:
    Sep 10, 2017
    Posts:
    5
    Hi @PhilSA, everything is running smoothly except I'm having a hard time getting prediction working with Rival. I have a feeling that it might be an issue with the NetCode documentation but I'm not sure.

    I think what I expect to see is the Rival.KinematicCharacter body showing up in bold
    upload_2021-6-13_18-42-39.png
    after including
    Code (CSharp):
    1. public class MobCharacterGhostOverrides : IGhostDefaultOverridesModifier
    2.     {
    3.         public void Modify(Dictionary<string, GhostComponentModifier> overrides)
    4.         {
    5.             // TODO: find a way to not have to clear defaults (translation/rotation)
    6.             overrides.Clear();
    7.  
    8.             var translationComponentModifier = new GhostComponentModifier
    9.             {
    10.                 typeFullName = "Unity.Transforms.Translation",
    11.                 attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false },
    12.                 fields = new[]
    13.                    {
    14.                         new GhostFieldModifier
    15.                         {
    16.                             name = "Value",
    17.                             attribute = new GhostFieldAttribute{Quantization = -1, Smoothing = SmoothingAction.InterpolateAndExtrapolate}
    18.                         },
    19.                     },
    20.                 entityIndex = 0,
    21.             };
    22.             overrides.Add(translationComponentModifier.typeFullName, translationComponentModifier);
    23.  
    24.             var rotationComponentModifier = new GhostComponentModifier
    25.             {
    26.                 typeFullName = "Unity.Transforms.Rotation",
    27.                 attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false },
    28.                 fields = new[]
    29.                    {
    30.                         new GhostFieldModifier
    31.                         {
    32.                             name = "Value",
    33.                             attribute = new GhostFieldAttribute{Quantization = 100, Smoothing = SmoothingAction.InterpolateAndExtrapolate}
    34.                         },
    35.                     },
    36.                 entityIndex = 0,
    37.             };
    38.             overrides.Add(rotationComponentModifier.typeFullName, rotationComponentModifier);
    39.  
    40.             var characterBodyComponentModifier = new GhostComponentModifier
    41.             {
    42.                 typeFullName = "Rival.KinematicCharacterBody",
    43.                 attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false },
    44.                 fields = new[]
    45.                    {
    46.                         new GhostFieldModifier
    47.                         {
    48.                             name = "RelativeVelocity",
    49.                             attribute = new GhostFieldAttribute{Quantization = 100, Smoothing = SmoothingAction.InterpolateAndExtrapolate}
    50.                         },
    51.                         new GhostFieldModifier
    52.                         {
    53.                             name = "IsGrounded",
    54.                             attribute = new GhostFieldAttribute(),
    55.                         },
    56.                         new GhostFieldModifier
    57.                         {
    58.                             name = "ParentEntity",
    59.                             attribute = new GhostFieldAttribute(),
    60.                         },
    61.                     },
    62.                 entityIndex = 0,
    63.             };
    64.             overrides.Add(characterBodyComponentModifier.typeFullName, characterBodyComponentModifier);
    65.  
    66.             var trackedTransformComponentModifier = new GhostComponentModifier
    67.             {
    68.                 typeFullName = "Rival.TrackedTransform",
    69.                 attribute = new GhostComponentAttribute { PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false },
    70.                 fields = new[]
    71.                    {
    72.                         new GhostFieldModifier
    73.                         {
    74.                             name = "CurrentFixedRateTransform",
    75.                             attribute = new GhostFieldAttribute{Quantization = -1, Smoothing = SmoothingAction.InterpolateAndExtrapolate}
    76.                         },
    77.                     },
    78.                 entityIndex = 0,
    79.             };
    80.             overrides.Add(trackedTransformComponentModifier.typeFullName, trackedTransformComponentModifier);
    81.         }
    82.  
    83.         public void ModifyAlwaysIncludedAssembly(HashSet<string> alwaysIncludedAssemblies)
    84.         {
    85.             alwaysIncludedAssemblies.Add("Rival.Runtime");
    86.         }
    87.  
    88.         public void ModifyTypeRegistry(TypeRegistry typeRegistry, string netCodeGenAssemblyPath)
    89.         {
    90.         }
    91.     }
    Which I found in the OnlineFPS sample. I'm just not sure what the steps are after or inbetween. I know that these fields need to be synced but without editing files to include [GhostField]s I'm not sure how to. I have also noticed an Assembly Definition Asset. Where must this be placed? Is it necessary?

    I understand that these things may not be an issue with Rival or the documentation so I apologise in advance.

    P.S. I cant get into the discord server with the link. Do I need an invitation?
     
  9. Lontis

    Lontis

    Joined:
    Sep 10, 2017
    Posts:
    5
    Changed a line in a Unity.NetCode.Editor file that was throwing a NullReferenceException from:
    Code (CSharp):
    1.                     attr = defaultComponent.fields.FirstOrDefault(f => f.name == componentField.Name).attribute;
    to
    Code (CSharp):
    1.                     attr = defaultComponent.fields.FirstOrDefault(f => f.name == componentField.Name)?.attribute;
    And now after hitting the [Update Component List] button:
    upload_2021-6-13_20-3-18.png

    So although now that I have the commands/and kinematic state synced, it still seems that my CharacterProcessor is behaves differently to the one in the OnlineFPS sample.

    What I'm looking to achieve is rubberbanding. Currently, pressing the forward key will not move my character forward until it's heard back from the server. I'm still digging through the OnlineFPS sample to find the difference between it and my project.

    thanks
     

    Attached Files:

  10. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    you can find more info on that here: https://docs.unity3d.com/Packages/com.unity.netcode@0.6/manual/ghost-snapshots.html

    Adding this might help fix the syncing issues


    Looks like the link I was using had an expiration date, I've updated it in first post!
     
    Last edited: Jun 15, 2021
  11. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Hi. Any new updates?
     
  12. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    So far I've tried a quick android build of the stress test scene, but I get a feeling that my settings for DOTS android builds must be wrong in some way. An empty scene with no characters runs at 15 fps on my galaxy s8

    I'll have to investigate further
     
    andreiagmu and optimise like this.
  13. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    hello dev
    i am considering purchasing your asset for testing purposes and before I do this i read you have specific requirements for version of unity and the use of DOTS and ECS

    however, since Unity recently changed dots to only manually inclusion of each and every dots package + dependencies, it is very difficult to know what is the best environment to set up to start with

    can you please include exact list of packages and also their version number or links to a list of these package names in manifest inclusion form (example: com.unity.entities), you use when developing and utilizing your asset, and also with sample packages, i understand that atleast these will be mandatory?

    com.unity.entities
    com.unity.rendering.hybrid
    com.unity.dots.editor

    unity has made a real mess of this situation, i do not want to sound demanding i just want to make sure i can test my dev environment for this set up prior to making purchases. thank you for your hard work (i am also thinking about your other asset Kinematic Character Controller, when i can afford to, thank you)
     
  14. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    @graphicsayy97

    The mandatory requirements are Unity 2020.3 and these packages:
    This page will tell you how to setup the whole project to make it DOTS-ready:
    https://philsa.github.io/rival-doc/Tutorial/tutorial-setup.html

    And the requirements for the samples are:
     
    andreiagmu and graphicsayy97 like this.
  15. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    thanks this helped me alot
    keep up the good work....
    also please consider making more assets like this for DOTS (maybe optimized third-person grappling hook system controller????! ill pay good money for that!)
     
  16. Metamulti

    Metamulti

    Joined:
    Jun 15, 2019
    Posts:
    4
    Hi there, did you check for mobile build on android or iOS?
    Did you find the android fps issue?
     
  17. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I'll be looking into this over the upcoming weekend
     
  18. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    56
    Wow, your asset looks like it might be a lifesaver for me. I need physics and high network performance for a Battle Royale Game but couldn't get the Ultimate Chatacter Controller to work with the new networking... so I will give it a try. The thing I would miss most is the awesome "Puppetmaster" Asset (Advanced Ragdolling). Do you think this could be integrated to rival or are these operating in seperate worlds?
     
  19. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    There would be no way of making both work at the same time, mostly because they both use a different physics engine

    Make sure you look a bit into DOTS before buying. If you've already started your project in monobehaviour, you'll need to restart everything from scratch if you want to use DOTS
     
  20. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    @Metamulti @optimise

    So I reinstalled my Android SDKs and whatnot, and now I'm getting results that make more sense. However, I haven't been able to make any android build work with IL2CPP, so this is from Mono builds. I also don't have an iOS device so I can't test that

    StressTest scene with 1000 moving characters on Galaxy s8 (notice the "StressTestCharacterJobs" in green at the bottom: about 7-8ms):


    However, the OnlineFPS sample seems to really struggle on my Galaxy s8. The weird thing is that it looks like the slowness is mostly caused by the "WaitForPresentOnGfxThread", which in turn causes the netcode prediction system to have to do many frames of re-simulation every frame, because the simulation rate is higher than the final framerate:


    I wonder if HybridRenderer V2 is safe for use on mobile at the moment (?). I think at this point, someone would have to do a DOTS + Netcode test on android that is completely unrelated to Rival. It would help removing variables from the equation
     
    Last edited: Jun 28, 2021
    andreiagmu likes this.
  21. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    Yes! You finally released it. Just saw this on https://www.reddit.com/r/UnityAssets/. So pumped glad you finally got it out. I saw a talk you gave on this a while ago and was hoping it would complete soon! Congrats!
     
    PhilSA likes this.
  22. GameDeveloper1111

    GameDeveloper1111

    Joined:
    Jul 24, 2020
    Posts:
    100
    Thank you for making Rival.

    ---

    EDIT: Resolution to the below issue:

    ---

    When I build the OnlineFPS sample and run it in a standalone player I get many leak warnings in the log. I don't get these warnings when I play in the editor.

    Log folder:

    %USERPROFILE%\AppData\LocalLow\PhilippeStAmand\Rival_OnlineFPS_Client5


    Leak warnings:

    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak


    and

    Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 5)


    Thread where I request help detecting standalone-only leaks:

    https://forum.unity.com/threads/standalone-leak-detection.1153565/
     
    Last edited: Aug 9, 2021
  23. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    I'm trying to create a RigAttach System and use Unity.Animation.Samples's socket demo as my reference.
    but i notice that in Rival, seems it didn't write AnimationStream back to Transform system, how can i solve this?

    thanks !

    -- UPDATE !! --

    After some dig, i notice that i forget to add `DefaultAnimationGraphWriteTransformHandle` or `LateAnimationGraphWriteTransformHandle` to the transform i want to expose, the concrete logic can be found in WriteTransformComponentJob.cs
     
    Last edited: Aug 11, 2021
    PhilSA likes this.
  24. Fedoolka

    Fedoolka

    Joined:
    Oct 4, 2018
    Posts:
    1
    Hi!
    I have some problems with physic when trying to implement client/server state (custom framework, not NetCode).
    So I have Client and Server worlds with separate movement systems, everything works fine except that when I move my character, it permanently goes to not grounded state and start sliding on platform, like on ice, until it stucked to corner, then it become grounded. I'm using third person character templates with little modifications to support multiple worlds.
    What can it be? What I need to check?
     
  25. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    it's pretty hard to tell without knowing exactly what modifications you made or how you support multiple worlds. Ideally you should have all of your physics objects in the same world as your character. I'd also try to validate that everything works in an offline game with a single world first, and only after having validated that I would tackle the problem in an online multiple-world setup
     
  26. Wenrong-Zhang

    Wenrong-Zhang

    Joined:
    Aug 28, 2014
    Posts:
    5
    Is Android unable to run, is it resolved?
     
  27. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    What I know so far is that the character controller works well on Android, but it's the rendering aspect of the Samples projects in particular that seems to cost too much frame time on Android. (see profiler captures above)

    At this point I haven't done more tests to try and determine the cause of this, but since there currently are know issues with DOTS and IL2CPP android builds, I think it would be preferable to wait for future DOTS releases before investing more time into this
     
  28. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Hi @PhilSA. Rival is not working properly anymore at latest Unity 2020.3.19. Can u take a look at it and fix it?
     
  29. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I'm seeing issues, but only with the OnlineFPS sample. I'm getting these when starting the game:
    Can you confirm that this is the problem you're seeing?

    However, this seems to be a problem with unity's own netcode package, which would be out of my control. There's this thread about it, but I see you're already in the replies there. I'll just add the link for others to see:
    https://forum.unity.com/threads/202...tion-cannot-access-a-disposed-object.1158956/
     
    graphicsayy97 and optimise like this.
  30. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    The manual mentions support for sliding on ice surfaces. Is there a sample on how to do that anywhere? I see the "IgnoreGrounding" tag in the Basic scene but that seems to disable friction entirely without a way to steer.
     
    Last edited: Oct 6, 2021
  31. MehO

    MehO

    Joined:
    Apr 23, 2016
    Posts:
    16
    Damn I missed the sale. Do you know when next one will be ? :D

    Asset is looking great by the way, can't way to dig through it !
     
    Antonidiuss likes this.
  32. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    Hi! Maybe you've already found it, but the Platformer Sample includes that feature.
     
  33. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    I am going through the Platformer sample and can't figure out the purpose of MeshRootEntity. Is that supposed to be the authoritative player rotation or is it the one on PlatformerCharacterComponent ?

    DashingState.cs:27 is a prime example of this; first MeshRootEntity.rotation is used, then the result is overwritten by PlatformerCharacterComponent.rotation
     
  34. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    This is a bit of a leftover from WIP features that didn't make the final cut in that sample. Mostly:
    1. Root motion
    2. A "sliding" state where we had to rotate the animated mesh (but not the capsule collider) to adapt to ground normal
    I should probably remove it in a future update to avoid confusion
     
  35. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    62
    Hello @PhilSA

    I've followed this part of tutorial: https://philsa.github.io/rival-doc/Tutorial/tutorial-charactersetup.html and I cannot find MainEntityCameraAuthoring anywhere in codebase (I've unpacked only what tutorial said to unpack, so no samples and no FirstPerson package).

    The character moves around but camera doesn't follow
    upload_2021-12-13_15-28-24.png

    Weirdly MainGameObjectCamera does assign the MainCameraSystem.CameraGameObjectTransform but
    MainCameraSystem.OnUpdate isn't called. The system isn't on the Systems list, as you can see here:
    upload_2021-12-13_15-24-58.png
    upload_2021-12-13_15-29-40.png

    Any advice?
     
  36. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    Do you have any recommendations on how to make a character drop cleanly out of climbing mode? Let's say I am climbing up the side of a cube, then reach the top and now want the character to pull himself up and resume walking on top.
    With the platformer example the character will climb up the wall, then crawl on the ground until I press F so it switches back to GroundMove state.
     
  37. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Hi, I'm very late for this reply (must've missed the notification), but I'll answer either way

    The `MainEntityCameraAuthoring` is the authoring component that's auto-generated from the `MainEntityCamera` component, which has a "[GenerateAuthoringComponent]" attribute

    You can add it using the "AddComponent" menu like this:


    I admit things can be confusing, because the name to search for is "MainEntityCamera", but the actual component name is "MainEntityCameraAuthoring":
     
  38. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    This would be a bit like combining the climbing logic with the ledge grab logic:

    Most of your climbing state would be the same as it is in the platformer sample, except you'd always do some casts to try and detect if there is a grounded surface above your character (something similar to what is done in LedgeGrabState.LedgeDetection())

    If a grounded surface is detected, you can play some sort of animation to make your character climb up to grounded surface, and then transition to regular ground move state
     
    Marco-Playable likes this.
  39. xseagullx

    xseagullx

    Joined:
    Nov 7, 2019
    Posts:
    24
    Hey, @PhilSA
    First of all, thank you for a great asset!
    I have a problem implementing AI moving with it though.
    What is the best approach for moving humanoid agents? MoveInterpolated or MoveAccelerated?

    Basically, I'm trying to make agent approach the point, and stop there.

    Interpolated works great for navigating path, and making sharp turns, but I struggle predicting braking distance (making agent overshoot destination, turn around and go back)

    With kinematic movement I can predict those, but steering becomes a challenge, unless acceleration is set really high. Also it adds floatiness to movement.

    Do you have any advice?
     
  40. Olog555

    Olog555

    Joined:
    Aug 20, 2017
    Posts:
    6
    @PhilSA
    Greetings, comrade! Recently bought your asset, quality work, everything works well. I've only run into one problem so far. When I try to make a build - the engine freezes and then crashes, what could be the reason for this?
    I did everything according to the instructions, the engine version is suitable, there are no errors in the console.
     
  41. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    62
    @PhilSA thanks for response. I assume it will work but sadly I cannot test it. One of methods in Graph Tools Foundation was marked as obsolete so I updated the package and now it's incompatible with animation package xD
    I don't recall updating anything in the meantime but it was a month ago, so maybe I tried something and forgot about it? Don't have time for that now. Will give it another try in the future.

    upload_2022-1-18_13-59-45.png
     
  42. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    At the moment I have to say I'm not sure of the best way to calculate this... but I'll keep a note of it so I can see if I can make some helpers for that once I have time

    One way of calculating it would be to run the function multiple times with a targetVelocity of zero until our velocity reaches zero, and keep track of the distance covered by doing this:
    Code (CSharp):
    1. float brakeDistance = 0f;
    2. float3 tmpVelocity = CharacterBody.RelativeVelocity;
    3. while(math.lengthsq(tmpVelocity) > math.EPSILON)
    4. {
    5.     CharacterControlUtilities.StandardGroundMove_Interpolated(ref tmpVelocity, 0f, TemplateCharacter.GroundedMovementSharpness, DeltaTime, GroundingUp, CharacterBody.GroundHit.Normal);
    6.     brakeDistance += math.length(tmpVelocity * DeltaTime);
    7. }
    ...but it's not the most elegant or efficient solution. I'm thinking it might be the only 100% exact way of doing it, since the result would be slightly different at a different deltaTime, but maybe there would be good-enough approximations that can be done at a lower cost
     
    Last edited: Jan 21, 2022
  43. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Can you share your Unity version and your OS?

    As of 2020.3.23f1, on Windows, and in a clean Rival Samples project, building with the various BuildConfigs seems to work without issues
     
  44. Olog555

    Olog555

    Joined:
    Aug 20, 2017
    Posts:
    6
    2020.3.0f1 Windows 10 x64, I will try your version.

    I tried yours, installed everything, loaded the asset according to the documentation. Everything works in the editor. I'm trying to make a build - it waits for a while, it gets to Mono.Tick and then it crashes

    Some times i get this in the console
     

    Attached Files:

    Last edited: Jan 21, 2022
  45. xseagullx

    xseagullx

    Joined:
    Nov 7, 2019
    Posts:
    24
    Basically doing the integration. I've done that in excel, and then also compared it with real world acceleration it would imply in different scenarios with different sharpnesses and so on. I didn't like what I got. Acceleration was variable, depending on the speed, and with low sharpness or high speed, braking distance was way too high for me to put a limit on steps I need to calculate. e.g. in some casess I needed to calculate 1.5 - 2 seconds until velocity drops enough.

    I ended up going for accelerated velocity. It requires quite high acceleration, but I can maybe later use a trick of having both acceleration and deceleration defined separately.
    And I have kinematic movement equations for all my queries, e.g. I can control the time it'll take me to get to destination, acceleration, everything.

    I think having the separate hepler class for that added to rival, and shedding a bit more light on MoveAccelerated can be a good idea. WDYT?
    Anyway, I've mostly solved the problem, and once again wanna thank you for a cool asset!


    Ah, before I forget. Is there a way ship it as a package? Right now I've done my own local package wrapping it, but it'd be great if just adding a line to manifest (or package dependenices) would work, and Rival will be neatly packed in Packages folder.
     
  46. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I'd have to refresh my calculus skills a bit, but I've always wondered if there's an *exact* way of calculating the area under a curve in programming languages, if you know the function of the curve. First I would work on figuring out what kind of function represents an interpolated velocity, and then maybe we could do something with that

    But after a quick google search, it looks like most people just calculate this by dividing the curve into steps and add them up. Basically the solution that was suggested earlier

    Yeah I think that would be a good thing to have. Perhaps even making the Move_Accelerated method take separate accel/decel parameters by default too

    There was a time when asset store people were talking about making all asset store products be actual unity packages by default, but unfortunately it's been a while since I've heard any news about that. Without that feature, I think it would be a bit too complicated for me to figure out how to host an up-to-date package of Rival but somehow make sure only people who have purchased it have access to it
     
  47. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    If you know it at compile time then you can just do the integration on paper, right? If it's a completely arbitrary function not known until runtime then numerical piecewise integration is the only way. If it's a compound function where some parts are known ahead of time you end up with the approach that TensorFlow is taking where each partial function knows its integral and they are combined at runtime.
     
  48. Marco-Playable

    Marco-Playable

    Joined:
    Nov 12, 2020
    Posts:
    53
    Just a heads-up of a problem that took some time to investigate: we have a somewhat unique approach where all characters come from a single prefab, then the entities get duplicated via EntityManager.Instantiate() and additional ECS components added to some of these instances.
    This reveals a race condition in the (parallel) RivalCharacterJob when one of the characters (using the platformer example) tries to climb. The ClimbingState morphs the underlying PhysicsCollider and because Instantiate only performs a shallow copy of the PhysicsCollider we now have morphed all spawned objects even if they live in a separate entity chunk.
     
  49. wooolly

    wooolly

    Joined:
    Aug 12, 2017
    Posts:
    9
    Hello. The asset looks very impressive, good job.
    I'm considering buying this asset but I just wanted to clarify whether it's suitable for my project. Does the character controller come with simple Move() methods for specifying positions to move characters to? I'm making a point-and-click RTS game in DOTS, and I need to give the character controller coordinates to move to, as opposed to WASD navigation. Is pathfinding supported, and if not, is it possible to implement pathfinding for this character controller? Likewise for AI characters, I'll likely want to have them randomly moving around the map, so presumably I'd want to achieve this in a similar way? Thanks!
     
  50. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    The character moves by setting a velocity, a bit like you would set a velocity on a rigidbody.

    For your use case, using rival would look like this:
    • Using the navmesh/pathfinding solution of your choice, calculate a path (list of waypoints) from your character position to its target destination
    • Give the Rival character a velocity that makes it go towards the next point in the path
    • Detect when a point has been reached, and update the next point in the path
    Keep in mind this is all stuff you would have to write yourself. Since DOTS doesn't have an official navmesh solution yet, I'll wait a bit longer before adding built-in support for this