Search Unity

[RELEASED] Rival - DOTS Character Controller

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

  1. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Yeah, so basically the way this would work is that you'd have an ECS system that knows about your character entity and your 3rd Person Starter animated character GameObject, and that system would be observing the character state in order to set mecanim parameters on the GameObject character.

    For example, that ECS system would be looking at the current velocity of the character Entity, and it would set a float "Velocity" Mecanim parameter based on that, so that the animation can transition from walking to running. (This is just an example, I haven't verified if the 3rd Person Starter character actually works like this)
     
  2. chefneil

    chefneil

    Joined:
    Aug 21, 2020
    Posts:
    29
    Couple of questions in this thread about ECS 1.0 support. I'm throwing my hat in the ring as someone eagerly waiting for ECS 1.0 support. Is there an official (or unofficial) response to this somewhere that I'm missing? I couldn't find anything on GitHub and the questions in this thread about it are suspiciously skipped over (despite your fantastic response times!)

    I really want to get on ECS1.0 and I'm wondering if I should migrate Rival myself or if we can expect some info about this in the next month or so...

    Thanks for your brilliant work, Cheers.
     
  3. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    A 1.0-compatible version is being worked on presently. The update is just taking longer than usual because there's a lot of very interesting new APIs in 1.0 that Rival could really benefit from, and updating all the samples & docs to reflect these changes takes a bit of time

    I'll post back here when I have dates I can share, but just know that it's for the near future. So the wait shouldn't be too long
     
  4. chefneil

    chefneil

    Joined:
    Aug 21, 2020
    Posts:
    29
    Amazing! Look forward to it!
     
  5. wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    Joined:
    Jun 28, 2021
    Posts:
    17
    I try to copy the whole scene, but it fails . The character not Spwan as normal.
    To reproduce the process :
    I create a right sample scene and than copy the scene. No Character Spwan and I find a lot of system not display in the System Debug Panle.

    what I ture want is Add a new Character to my scene.I really can't help it. by the way , I succeed add threePersonCharacter to my Project.
     
  6. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    This might be due to the
    SamplesBootstrap
    . Because there are several different games living in the same Unity project, I made the bootstrap filter out systems to create on start based on the name of the scene used to start the game.

    You can find this code in a switch statement at the start of the
    SamplesBootstrap.Initialize()
    function, if you'd like to add new scenes to it.

    In the next update, samples will become individual Unity projects to make this less complicated
     
  7. wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    wechat_os_Qy07oG6LBuLwxrt0ao4ZkEwPc

    Joined:
    Jun 28, 2021
    Posts:
    17
    Oh my god.I would spend my whole life on this if not for this post.Anyway thank you for such a quick reply.I can slove it.
     
  8. akbuehner

    akbuehner

    Joined:
    Jul 13, 2020
    Posts:
    3
    I was able to modify the scripts and get them working in Unity 2022.2.0b13 with ECS and Physics 1.0.0-exp.12. I did not refactor for the 1.0 API improvements so it may not as performant as it could be, just enough to get it to run. I have not tested it thoroughly but if you are interested you can find my updates here: https://github.com/akbuehner/rival-ecs1.0

    Thanks for making a great free asset.

    I eagerly await the official 1.0 version
     
    Last edited: Nov 22, 2022
    Vacummus and Opeth001 like this.
  9. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,271
    I just saw that Rival is now UCL! Thank you! I'm looking forward to being able to include it in samples now!
     
    philsa-unity likes this.
  10. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
  11. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Note: in the samples, you may notice jittering when interacting with any moving rigidbody (moving platforms, boxes, vehicle, etc...). This is a known issue, and is simply due to the fact that I had to disable interpolation on these rigidbodies because of a baking issue that will be fixed in a future Entities release.

    The issue in question is a baking error that happens when a rigidbody has interpolation AND a non-unit scale.

    The smoothness will return :cool:
     
    Last edited: Dec 9, 2022
    akbuehner and Opeth001 like this.
  12. akbuehner

    akbuehner

    Joined:
    Jul 13, 2020
    Posts:
    3
    I'm removing this github as the official version has arrived and works great
     
  13. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Firstly, thank you for such a fantastic asset. As mentioned above, this has saved me a mammoth amount of polish. The Platformer sample in particular is beautifully handled, and I've already plugged it into my project to replace my earlier implementation derived from the Physics samples. Very slick.

    This leads to my only issue. I've tried building and running both the platformer sample project without any modification, and my own project. In both standalone builds, the character only plays the sprint animation, for all other states the mesh stays in the t-pose. This is on OSX standalones, I haven't tested PC yet. Unity 2022.2.0f1, Entities 1.0.0-pre.15, latest Rival package and a fresh pull from github.

    I'll replace the demo mesh with my own character later, but wanted to check it wasn't something on the DOTS side of things. Thanks!
     
    dwulff likes this.
  14. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    have you tried disabling the Managed code stripping in Edit > Project Settings > Player ?
     
    Karearea likes this.
  15. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    It's building to IL2CPP with 'minimal' stripping.

    Edit: Implemented my own character mesh/animator and all works well. Even extended it a bit to handle various jump landings and an enter/exit system. Rival is a fantastic asset, thanks again!
     
    Last edited: Dec 18, 2022
  16. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    515
    Anyone done a netcode for entities sample demo for the platformer sample demo?
     
  17. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    No, but I'm in the process of using the FPS Sample to get my character working and having some problems.

    @philsa-unity I have a couple of questions as I'm struggling to get things working.

    First of all, a curiosity that I suspect might be a problem and related to my main question.
    On the character controller's ghost inspector, if I set the LocalTransform optimisation to 'Never Send', I kind of expected that to mean "my prediction will never be overwritten by snapshots". Is this the case? When I set this to Never Send, my character is going SUPER FAST on the client. I have verified that this is also the case in the FPS Sample. Does this imply the client-side prediction code is not matching what's occurring server-side?
    upload_2022-12-28_9-10-49.png

    That was a lead in to my main question.
    In my game, I will be toggling between first and third person views, but let's focus on third person for now.
    My character is fully visible, and there is a game object proxy whose translation is tracking the character entity.
    Tracking this proxy is a cinemachine orbit camera.

    I'm getting crazy amounts of jitter which disappears completely if I switch the character ghost from owner predicted (or just predicted) to interpolated.

    So, I went into the OnlineFPS sample, added a capsule so I could see the player, created a GameObject proxy follower, and an orbit cam following it. I was able to reproduce the jitter.

    I'm guessing the sample doesn't care about as in first person with a locked camera it just doesn't matter, and other characters are interpolated anyway. (I haven't tested, but I wonder if the jitter will show up on other players if they are predicted from their inputs.

    Any thoughts on how I should approach removing owner predicted jitter? Cheers.

    Jitter - Owner Predicted:

    Non Jitter - Interpolated:
     
  18. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    A couple of FYIs too.

    In the Basic Sample demo scene, when I stand on this platform which rotates around in place, the platform jitters a lot.
    This does not seem to be a problem with the moving platforms that are not rotating.

    (Edit: I see this is addressed in a post above regarding baking limitations.)

    Secondly, in the Rival Runtime, the
    CharacterInterpolation
    IComponentData has attribute
    [WriteGroup(typeof(LocalToWorld))]
    . This is preventing the TransformSystem from copying LocalTransform to WorldTransform on root entities. I have written a little system to copy this myself after the
    CharacterInterpolationSystem
    runs.

    Cheers :)
     

    Attached Files:

    Last edited: Dec 29, 2022
    redwyre likes this.
  19. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    For other rival users, this came up for myself and another user, so figure it might come up for more of you.
    If you find that your character's WorldTransform is not updating despite your LocalTransform updating, there is a little issue with WorldTransforms not updating. Here is a system you can add that will fix it for you until the next Rival update.

    Code (CSharp):
    1. using Rival;
    2. using Unity.Burst;
    3. using Unity.Entities;
    4. using Unity.Transforms;
    5.  
    6. namespace YourNamespace
    7. {
    8.     /// <summary>
    9.     /// Rival has a WriteGroup on component <see cref="Rival.CharacterInterpolation"/> that prevents the
    10.     /// TransformSystem from updating the WorldTransform. This system copies LocalTransform to WorldTransform
    11.     /// for any root objects with the CharacterInterpolation component.
    12.     /// </summary>
    13.     [UpdateInGroup(typeof(TransformSystemGroup))]
    14.     [UpdateBefore(typeof(LocalToWorldSystem))]
    15.     [UpdateAfter(typeof(CharacterInterpolationSystem))]
    16.     [WorldSystemFilter(WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation)]
    17.     [BurstCompile]
    18.     public partial struct CharacterInterpolationWorldTransformFixSystem : ISystem
    19.     {
    20.         public void OnCreate(ref SystemState state) { }
    21.  
    22.         public void OnDestroy(ref SystemState state) { }
    23.  
    24.         [BurstCompile]
    25.         public void OnUpdate(ref SystemState state)
    26.         {
    27.             new CopyTransformJob().Schedule();
    28.         }
    29.  
    30.         [BurstCompile]
    31.         [WithAll(typeof(CharacterInterpolation))]
    32.         [WithNone(typeof(Parent))]
    33.         private partial struct CopyTransformJob : IJobEntity
    34.         {
    35.             private void Execute(ref WorldTransform worldTransform, in LocalTransform localTransform)
    36.             {
    37.                 worldTransform = (WorldTransform)localTransform;
    38.             }
    39.         }
    40.     }
    41. }
    42.  
     
    dwulff likes this.
  20. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    LocalTransform ghost "Never Send" problem:
    If the character is going super fast, that might be a sign that the character transform is never getting rolled back to a previous state. So re-simulations just keep adding on to the position without reverting. My guess is that "Never Send" makes it so that the server never sends the state of the character transform to predicting clients, and so the transform never gets rolled back

    Third person jitter:
    Just to make sure I understand; did the manual WorldTransform update fix that issue?

    Jitter when standing on moving platform in Basic sample:
    This is a known issue, due to a baking bug that happens when a rigidbody has both a non-unit scale and interpolation. It gives you an error saying PostTransformScale can't be added twice to the same entity, and results in a failed baking. In order to not have these errors pop up when users open the samples, I've simply removed all interpolation from sample rigidbodies while we wait for the fix to land. So basically; the jitter is because moving platforms are temporarily not interpolated
     
    Last edited: Dec 30, 2022
  21. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    No, it didn't, although I didn't apply that fix to the sample scene to check there.
     
  22. Christopher-Anderson-GISP

    Christopher-Anderson-GISP

    Joined:
    Mar 5, 2015
    Posts:
    19
    Is Rival compatible with Unity 2022.x? I'm getting a lot of missing namespaces after importing it into a new empty project (i.e. ColliderCastHit, DistanceHit, PhysicsMass, etc.). I wasn't sure if it was something I did.
     
  23. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Those are members of the unity physics package which rival depends on. You need to make sure you have imported all of the dependencies too via the package manager.
     
  24. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Sorry for the delay, coming back to this now

    What does your gameObject proxy follow, and at what point in the frame? Ideally, you should make sure it follows the character's LocalToWorld (not LocalTransform or WorldTransform, as these aren't interpolated). It should be done after the TransformSystemGroup updates in the frame, but before Cinemachine updates. Cinemachine should also be configured to update on regular or late update (not fixed update). So to summarize, things must happen in that order:
    1. TransformSystemGroup updates the interpolated character transform in LocalToWorld component
    2. Your gameObjectProxy copies the interpolated character LocalToWorld
    3. Cinemachine follows your gameObjectProxy
    This sounds like a case where you should try to make things work offline first, like testing this cinemachine setup with the standard third person character. Then, only if everything works fine, we can consider how netcode affects all this
     
    Last edited: Jan 5, 2023
  25. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    This completely fixed the issue. I copied LocalToWorld to WorldTransform instead of LocalTransform in my 'fix' system above. Thanks for the help.
     
    Last edited: Jan 7, 2023
  26. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Hello, a new question now. With netcode wanting to run the prediction group multiple times per frame, and each time running the physics systems like BuildPhysicsWorld, Simulate, Resolve Jacobians etc, CPU time can get out of hand very easily when a bit of lag is introduced.

    I figured for my project, I don't really need physics, so I'd like to disable the physics simulation if possible.
    But then I realised the whole moving platform system depends on it.
    Although I'm not sure if I will use moving platforms or not yet, I'd like to get some understanding up front.

    Is it possible to write a moving platform system that doesn't require the physics simulation to be running? I understand the character requires platform velocity to resolve its own position correctly, but is that something I can do without having physics move the transforms? Perhaps I can write velocity, and then use it myself to update transforms?

    Assume all I need is kinematic platforms. :)

    Cheers.
     
  27. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    This should be possible. You're allowed to move a moving platform directly using just the transform instead of physics velocity. As long as it has a TrackedTransform, the character will understand how to stand on it.

    The only thing that wouldn't work out of the box is the transfer of velocity from moving platform to character when the character is not standing on it (so when the character is pushed on the side by the platform). The character will still be pushed, but it won't inherit the momentum of the platform. Here's a video that demonstrates this:


    The first platform being interacted with here moves with transform, while the second one moves with velocity. Notice how the character doesn't keep any momentum from the first platform's push, even though it does get pushed. Depending on your game, chances are this limitation won't be a big deal.

    If you want to implement this momentum yourself though, you could do something like this:
    • Have your own "velocity" field for your platforms, stored in a component
    • At the end of the character's PhysicsUpdate, (mostly after CharacterAspect.Update_MovementAndDecollisions), iterate on character hits to see if you've had a hit with a moving platform of yours
    • For each moving platform hit, get the component on it that stores your custom moving platform velocity, and calculate a velocity change to apply to the characterBody.RelativeVelocity (calculate the difference between their velocities projected on the collision normal, and apply it to the character if that difference is going towards the character rather than towards the platform)
     
    Micz84 and Shinyclef like this.
  28. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Brilliant this is perfect thank you :D
     
  29. Nams33

    Nams33

    Joined:
    Oct 14, 2018
    Posts:
    6
    Hello,
    I am currently experimenting a lot with Rival, nice job so far !

    1)
    Though, I am wondering how to properly handle the raise of CollisionEvents. As Rival's character controller is using Decollision (DecollideFromOverlaps) or projection of movement to restrict movement (DetectMovementCollisions), the physic system does not trigger CollisionEvents if the resolution is done in a single frame.

    How to properly handle CollisionEvents then ?

    2)
    On an other topic, I found some discrepencies between manual phisic collision requests and collisions handled directly by Unity.Physics that might interest you.
    https://forum.unity.com/threads/inc...n-detections-using-calculatedistance.1388943/
     
  30. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Collision events are a special case for characters; you can look at this tutorial section that demonstrates how to do it: https://github.com/Unity-Technologi...lob/master/Tutorial/tutorial-characterhits.md

    Essentially, character hit events live in dynamicBuffers of character hits on the character entity. The reason why they're handled differently is because character collisions are not solved by the physics engine. You could still get some regular physics collision events raised between a character collider and something else, but this won't be reliable because the character will solve certain hits before the physics systems have a chance to detect them

    I've answered question #2 in the other thread
     
    Last edited: Jan 20, 2023
    Nams33 likes this.
  31. Nams33

    Nams33

    Joined:
    Oct 14, 2018
    Posts:
    6
    Exactly what I needed. Thanks for pointing this up !
     
  32. HallowedTree

    HallowedTree

    Joined:
    Apr 5, 2021
    Posts:
    6
    I love this asset and am building on it for my own controller. However, I wonder if anyone knows a more DRY way to represent the multiple switch statements in the state machine for the platformer sample?
    I have tried writing a function that returns the current state but this apparently cannot be used in a burst context. It seems shamefully verbose to have to write out the same switch statement for every method in the state machine, but is this simply the price for using burst?
     
  33. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    I can think of two potential approaches:
    1. Function Pointers: The strategy would be to store a function pointer for each function of each state. When the statemachine transitions to a new state, we can store the function pointers of all functions of that state as the "currentState" function pointers. Then the character update just calls the function pointers of the current state. Something to keep in mind is that with this, you lose the ability to store data per state. But you can simply store that data in one of the character components instead
    2. Codegen: A while ago, I wrote this tool that allows you to sort-of imitate polymorphism in DOTS. It's essentially a tool that codegens a union struct of all possible "child structs" of a certain interface, and codegens switch statements to trigger the right function depending of which form the union struct should currently be assuming. There's an example state machine implementation using this if you follow the link. However, I haven't maintained this project in a while and I can't guarantee it still works with 1.0. It has also been pointed out that it really increases compile time by a lot in large projects
     
    Last edited: Jan 31, 2023
  34. Chrispins

    Chrispins

    Joined:
    Dec 9, 2014
    Posts:
    15
    Hey guys, I'm putting together a game prototype with a heavy focus on characters freely walking/jumping around on large moving "ships". I'm loving the movement system as it reacts to static geometry, but understandably so, it doesn't seem so robust on moving platforms:


    (Note: "Interpolate Position" was disabled under "Character Properties", and "Smoothing" was set to "None" under Physics Body component of the moving platform)

    See the above gif and notice how character movement direction is not consistent with the spinning platform's current rotation. I'm only pressing W and S to move back and forth, but the character movement trajectory (relative to the platform) changes once the platform begins to rotate. Also less obvious, the character's rotation will slowly lag behind the platform rotation as time goes on, in a jittery fashion.

    I apologize if this question is too general, but is there an elegant solution for this? I'm wondering if I need to rework the character controller such that data components like 'characterPosition' and 'characterRotation' are replaced with 'characterLocalPosition' and 'characterLocalRotation'. Then, have the movement system set the final character transform based on the current parent transform. I'd at least like to know if I'm on the right track...

    Right now, I see that the TrackedTransform system simply tries to match the velocity of the character to the parent entity, but I'd like the character to behave as if each moving platform were its own "world" so-to-speak with its own local coordinate system that the character moves within.
     
    Last edited: Feb 11, 2023
    Faahhx likes this.
  35. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    I've been looking into this. The good news is that there's a way to fix it right now without waiting for a package update. The bad news is there is a LOT to explain :D. There are several different issues happening at the same time here, and the fix comes in multiple steps:

    1- Ensure you have "Synchronize Collision World" enabled in your "PhysicsStep"
    Add a "PhysicsStep" to your subscene and enable "Synchronize Collision World". Without this, the character might fall off of the rotating platform if it's somewhat close to the edge. This is because the platform collisions wouldn't be updated after the platform rotated, and therefore the character could fail to detect the ground at the new rotated position, depending on the shape of the platform.

    2- Rotate your character's "characterControl.MoveVector" and "characterBody.RelativeVelocity" before using them
    At the beginning of your aspect's "HandleVelocityControl()", before calculating new velocities, add the following code:
    Code (CSharp):
    1.  
    2.         // Rotate move input and velocity to take into account parent rotation
    3.         characterControl.MoveVector = math.rotate(characterBody.RotationFromParent, characterControl.MoveVector);
    4.         characterBody.RelativeVelocity = math.rotate(characterBody.RotationFromParent, characterBody.RelativeVelocity);
    This will ensure that the character's movement takes into account the platform rotation that happened after the player system wrote to the character control component to give it a worldspace movement vector. This gets rid of the offset between camera direction and character movement. I think I'll be adding this by default to the Standard Characters as part of future releases.

    3- The jitter problem
    Based on your reply, I think you already understand what the problem is, but I'll explain it anyway for other people. First, take a look at the image in attachments:
    • The green circle represents a top-down view of a circular moving platform that rotates really fast
    • The red circle is the character position on FixedUpdate1
    • The orange circle is the character position on FixedUpdate2 (resulting from platform rotation)
    • The black curved line is what the character position should be on interpolated frames between the two fixed updates
    • The grey line is what the character position actually ends up being on interpolated frames between the two fixed updates, due to how interpolation works.
    The fact that character position interpolation follows the grey line instead of the black line is reason why you see jitter (interpolation just goes from one point to the next; it doesn't know about "parents"). The problem becomes more obvious with a fast-rotating platform, and when you're far away from the platform origin.

    You would have the exact same problem if you attached a dynamic interpolated rigidbody with a physics joint to the edge of the moving platform. In the video below, I've set an extremely high fixed timestep (1s) in order to make the issue easier to understand. You can see the red box (rigidbody attached with joint) and the white character capsule both interpolating directly towards their next point instead of taking the platform's rotation "arc" into account:


    For the time being, I would say the solution to this is to make sure everything is updated on fixed update with no interpolation:
    • No moving platform interpolation
    • No character interpolation
    • Move character rotation code from the aspect's "VariableUpdate" to the "PhysicsUpdate". For example, you could copy/paste the rotation code at the end of "HandleVelocityControl"
    • Move camera update code to the fixed step group, after the character update. Keep in mind the camera update code will have to be changed in order to rely directly on simulation transform values, and not on the LocalToWorld since its values will be from the previous frame. I've attached a "OrbitCameraSystem" and a "TransformUtilities" that you can add to your project in order to handle that. These aren't extensively tested but they should do the trick. If you use mouse input, you'll also have to figure out how to "accumulate" mouse deltas on every regular frame, and pass this "total mouse deltas since last fixed update" value as input to the camera for its fixed update. Otherwise you'll be missing some mouse move inputs. You don't have to do this for gamepad analog stick camera controls though, because that's a constant value and not a "delta".

    Another alternative would be, as you implied, to explore a custom, more costly interpolation approach that understands parent velocities and how the character relates to parents. However, this will be on my todo list for future work and there are no immediate plans for it. It shouldn't be too much trouble to add this yourself though if you just turn off all built-in interpolation, create your own interpolation component to store values, and create your interpolation job that uses that component (you can use the existing jobs as reference). Off the top of my head, I'd say if you make interpolation rely 100% on characterVelocity, parentVelocity, parentAngularVelocity, and characterPosRelativeToParent instead of relying on previous/current character transforms, that should do the trick
     

    Attached Files:

    Last edited: Feb 11, 2023
    Chrispins likes this.
  36. Chrispins

    Chrispins

    Joined:
    Dec 9, 2014
    Posts:
    15
    Thank you for the swift reply! I truly didn't expect for you to get so far into the weeds of the moving platform logic, but it illuminated well the solutions that I need try next. Very good explanation on the interpolation issue :cool:
    I understood interpolation was part of my problem, but didn't know exactly how and why..

    I'll first say that adding the code snippet for updating the character MoveVector after the platform rotates during the frame worked like a charm! The character now moves in the expected direction while the platform is spinning.

    I enabled "Synchronize Collision World" under the PhysicsStep component as well. I didn't notice any significant change, but I can see where this should help. There are still cases where the character will seem to bump downwards and detach from the parent at the leading edge ("front") of platforms as they move at very high speed, but it's no big deal to me because I plan to have a custom 'attach/detach' logic. See gif below if you're curious what the 'bumping' looks like:


    I tried to add your updated "OrbitCameraSystem", but ran into a snag as it appears the TrySetToWorldTransformUnscaled() method is missing from the
    WorldTransformsHelper struct in "TransformUtilities"?

    I haven't yet tried to update character rotation on the PhysicsUpdate rather than VariableUpdate, but honestly I'm starting to think I need to do that custom solution after all. I would prefer to have smooth interpolation enabled for at least the character and camera, instead of being locked to whatever the physics fixed timestep is (50 ticks per second by default?). Also, if I want to implement fast-paced multiplayer, interpolation is quite an important feature I feel.

    I'll be sure to give an update on my journey if I manage to figure this out :)
    Thanks for the help!
     
    Last edited: Feb 11, 2023
  37. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Oh my bad, here are the updated files in attachments

    I'll try to repro this on my side and see what I can find; it definitely looks like something that shouldn't be happening
     

    Attached Files:

  38. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    @philsa-unity
    I'm having some issues using Unity 2022.2.5f1 and Entities 1.0.0-pre.15

    after importing the Rival asset I immediately had errors

    first one is there are multiple .asmdef files in the Runtime folder:

    Rival.Runtime.asmdef and Rival.asmdef

    After deleting the Rival.Runtime.asmdef I had some compiler issues with

    KinematicCharacterDeferredImpulsesJob.cs

    - It didn't properly implement IJobBatch interface. parameter "in v128 chunkEnabledMask" was missing.
    - it was still using older Translation and Rotation instead of the new combined LocalTransform.
    - it was trying to access deferredImpulse.Impulse from KinematicCharacterDeferredImpulse but there is no Impulse field. so i tried substituting with what was available: .LinearVelocityChange and .Displacement

    i made sure to update the package before importing it
    any ideas?
     
    Last edited: Feb 28, 2023
  39. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    First off, you should try a clean re-download Rival from the store (delete everything first). There shouldn't be multiple asmdefs

    If that still doesn't work though, it's possible a versions mismatch between Unity, Rival, and other DOTS packages is causing these issues. I'd suggest you try either of the following versions combos:
    • Rival 1.0.0-pre.15.1, Unity 2022.2.1, DOTS pre.15 packages
    • Rival 1.0.0-pre.15.1, Unity 2022.2.6, DOTS pre.44 packages

    Also, if you get errors on import, try to right-click in your Project window (like in the Assets folder) and click "Reimport all"
     
    Last edited: Mar 1, 2023
  40. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    Appreciate the reply. Deleting Rival and re-importing it again made it work for whatever reason :D
    Previously I tried just re-importing it without any luck

    However, following the Tutorial I simply cannot get the Character to move or even respond to physics.
    I follow the tutorial step by step.
    Make a subscene, add the third person characters/camera to it. assign the components to the cameras, wire up the Controlled Character/Camera.
    Press play and nothing happens.
    I see in the Entities Hierarchy that the subscene has (not loaded). This is so frustrating
     
    Last edited: Mar 1, 2023
  41. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Any errors in the console when you try to open/close the subscene?
     
  42. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    nope :(
    i tried closing / opening / unloading / loading
    if i set the conversion to Runtime for the subscene I can see the gameObjects as entities with their respective components. But when I hit play the subscene is says (not loaded) and i don't see any entities in the Entities Hierarchy

    edit:
    i fixed the issue by creating an entire new project and now everything works.

    not to be a jerk but i cannot fathom what is going on with Unity lately. adding to the list of frustration and confusion, i notice that Rival has [deprecated] prepended to its name in the Packager Manager. The deprecation notice says Rival is now its own package at
    com.unity.charactercontroller


    trying to add it by that package name will fail to find it.
    the documentation link from the package:
    https://docs.unity3d.com/Packages/c.../index.html?subfolder=/manual/get-started.htm
    takes you to a "Sorry page is missing"
     
    Last edited: Mar 1, 2023
  43. joaoborks

    joaoborks

    Joined:
    Jul 7, 2015
    Posts:
    29
    @StayThirsty it works if you manually add the package to the manifest.json:


    "com.unity.charactercontroller": "1.0.0-exp.2"


    Keep in mind, they changed the asmdef file so make sure you replace the previous "Rival" asmdef reference with the new "Unity.CharacterController" and do the same for the using namespace references inside your code.
     
  44. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    Could you let me know which link this is? I've re-tested both the link on the asset store page and the "Documentation" link in the package manager, and both appear to be working, at least on my side. I've noticed the link in your post is missing an "l" at the end of "html", but I don't know if that's a copy/paste mistake or if it's really the link you copied

    As for adding the package by name, did you try:
    • Unity 2022.2.6
    • Capture.PNG
    • com.unity.charactercontroller
     
  45. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    interesting. still it should work via add package by name

    hi, yes i tried via add package by name but still in Unity 2022.2.5f1
    upload_2023-3-3_20-17-38.png

    as for the link you're right. the missing 'l' was the culprit. to catch the missing 'l' i have to select the trailing `)`. my mistake :oops:
     
    Last edited: Mar 14, 2023
  46. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    @philsa-unity
    Are there any plans to have this working with Netcode for Entities?

    I'm trying to make changes to get Rival to work with Netcode but I am having some problems with jittering
    (see attached files) with moving and jumping

    I am looking thru the OnlineFPS example and trying to copy what was done there to the Rival character controller but I am not having much success yet.

    Could you tell me what I need to change to get Rival to work with Netcode without jittering? I have the whole client/server and input working. My main issue is the jittering

    The jittering doesn't seem to happen in the Scene View (it used to, but I must have fixed this when copying over stuff from the OnlineFPS sample) so it must be related to the OrbitCameraSystem?

    Also my character occasionally jumps 2 or 3 times instead of just once. Any idea what could cause this?

    I have done:
    • Copying GhostVarient.cs from OnlineFPS to remove Server side Client Interpolation
    • Changed the UpdateGroups to the appropriate ones (copied these from OnlineFPS so I hope this is correct)
    Thank you
    @Shinyclef hi, have you managed to solve the jittering problem?
     

    Attached Files:

    Last edited: Mar 14, 2023
  47. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    115
    I would suggest going over every step described in this page:
    https://docs.unity3d.com/Packages/com.unity.charactercontroller@1.0/manual/networking.html

    The multiple jumps might indicate a problem with input handling. Be sure to check out how IInputComponentData works here:
    https://docs.unity3d.com/Packages/com.unity.netcode@1.0/manual/command-stream.html
     
  48. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    Thanks! I completely missed this documentation
    So I had went through it, this is what I've done:

    Ghost component setup
    • Right now I have 1 entity with both the ThirdPersonPlayer and ThirdPersonCharacter components, is that a problem?
    • Otherwise they are Owner Predicted and Has Owner.
    • AutoCommandTarget is enabled
    • I assume Track Interpolation Delay is CommandDataInterpolationDelay. I added those and set it to 0 on client, 6 on server

    What to synchronize on the character and
    Character interpolation


    I believe I have both of these taken care of using this GhostVariant script:

    Code (CSharp):
    1. public class DefaultVariantSystem : DefaultVariantSystemBase {
    2.     protected override void RegisterDefaultVariants(Dictionary<ComponentType, Rule> defaultVariants) {
    3.         defaultVariants.Add(typeof(LocalTransform), Rule.ForAll(typeof(TransformDefaultVariant)));
    4.         defaultVariants.Add(typeof(KinematicCharacterBody), Rule.ForAll(typeof(KinematicCharacterBody_GhostVariant)));
    5.     }
    6. }
    7.  
    8. [GhostComponentVariation(typeof(KinematicCharacterBody))]
    9. [GhostComponent()]
    10. public struct KinematicCharacterBody_GhostVariant {
    11.     [GhostField()]
    12.     public float3 RelativeVelocity;
    13.     [GhostField()]
    14.     public bool IsGrounded;
    15. }
    16.  
    17. // Character interpolation must be Client-only, because it would prevent proper LocalToWorld updates on server otherwise
    18. [GhostComponentVariation(typeof(CharacterInterpolation))]
    19. [GhostComponent(PrefabType = GhostPrefabType.PredictedClient)]
    20. public struct CharacterInterpolation_GhostVariant {
    21. }
    22.  
    23. [GhostComponentVariation(typeof(LocalTransform))]
    24. [GhostComponent()]
    25. public struct LocalTransform_Character {
    26.     [GhostField(Smoothing = SmoothingAction.InterpolateAndExtrapolate)]
    27.     public float3 Position;
    28. }
    Prediction
    I have double-checked everything here to make sure I have these changes

    Player commands
    I am using the netcode references here so I believe its fine, the character does move after all :)

    Third Person Character synchronization
    Does this mean I must spawn a Camera on the server to get it to work?

    I can't use subscenes/baking/authoring with WebGL, so I'm manually spawning prefabs using GhostPrefabCreation. Not sure how to unsync Physics Velocity :(

    Any ideas? Sorry for the long post
     
    Last edited: Mar 21, 2023
  49. Dainofel

    Dainofel

    Joined:
    Oct 12, 2019
    Posts:
    35
    Hello,

    I bought this asset and have been using it on entities 0.5.0 no problem.

    Today I wanted to update to entities 1.0, and I found that the asset is deprecated on the store?

    Where can I get this asset that is compatible with entities 1.0?

    Thanks for the help
     
  50. Dainofel

    Dainofel

    Joined:
    Oct 12, 2019
    Posts:
    35
    Nevermind, I just read the last few posts and understand that is a new separate package. I will update to the latest 2022.2 version and download it like that.
     
    Last edited: Mar 17, 2023