Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How would you go about making a 'basketball' type object?

Discussion in 'FPS.Sample Game' started by Shhteve, Nov 12, 2018.

  1. Shhteve

    Shhteve

    Joined:
    Jan 23, 2013
    Posts:
    5
    The game I'm modifying the FPS Sample into requires me to have a single scene-object that players on either team can pick up and score in each other's bases.

    So far my strategy is to modify the Grenade module to fit my needs. I'm new to using ECS, so this whole thing is pretty experiment/learning heavy, and I just wanted to check with you fine folks to see if anyone can think of a good way or good starting point for implementing something like this?

    *COUGH* or if the Unity team is already working on a CTF game mode and I should just be patient *COUGH* :)
     
  2. Mogens_H

    Mogens_H

    Unity Technologies

    Joined:
    Mar 7, 2017
    Posts:
    20
    Sound like a fun idea.
    First thing to note is that the grenades are moved using our own code and we dont use physics system and rigid body (as you probably have seen from the code). This gives us more control over movement and allows us tweak it for gameplay purposes.
    IMO it would be a good idea to use same approach for your "ball" - and - you need to do some changes in the ServerGameLoop if you want to use the Unity physics system to drive the positions. The server currently generate snapshot at the end of update, but if we wanted to drive replicated properties from physics we should generate snapshot in LateUpdate (after physics system has run). We are considering moving snaphot to LateUpdate -but I dont know when that will happen.

    I think using grenade+launcher is a good idea. You could change grenadelauncher to start with 0 ammo and change grenade behavior to add one ammo instead of doing damage. We dont have a good way to create custom behavior for different grenade types - so perhaps you can just add a "update type" propety and branch for that in the grenade systems.
    Regarding pickup: we hope to add some kind of simple pickup soon (probably health)

    CTF? Not something we have planned
     
  3. Shhteve

    Shhteve

    Joined:
    Jan 23, 2013
    Posts:
    5
    Thanks for the response, definitely feels good to have some confirmation I'm more or less on the right path :)

    So far everything I've been able to implement has been based off of modifying existing behaviours. I took Sprint and turned it into a Slide ability, I took Melee and turned it into a Use ability, and now I'm taking the Grenade and turning it into a pickup.

    Good to know about the ServerGameLoop, is there anything that would depend on the snapshot NOT being in LateUpdate? Thus far I've tried to adhere to the same lack of use of the physics system, mostly because deviating from any code examples in any way produces untold numbers of bugs, now I know why!
     
  4. Mogens_H

    Mogens_H

    Unity Technologies

    Joined:
    Mar 7, 2017
    Posts:
    20
    Well - actually I am wrong about the physics system. It is of course updated before Update so you should be able to replicated simulated objects (without one frame delay). We actually have a debug system (Moveable) that can be used to spawn simulated and replicated boxes that are interpolated on the clients.

    The reason we dont generate snapshot in late update is that the server can perform multiple tick updated per Unity frame (see while loop in UpdateActiveState). This means we generate snapshot before animation is run -but that is not a problem as animation result only is used to store hit collision positions, and hitcollision tests are always performed on "old" ticks (server side lag compensation)
     
  5. Shhteve

    Shhteve

    Joined:
    Jan 23, 2013
    Posts:
    5
    So I've moved away from using the Ability_GrenadeLauncher style of creating the basketball and just placed the ball in the scene as a SceneEntity (the ball needs to always exist for all players, each player can pick it up, throw it, drop it, etc, hence my question about CTF mode :) ).

    My problem is, from what I can tell/understand, the server is not generating a snapshot of the basketball to send to the client once the basketball hits the floor and stops moving, since it isn't considered dirty. So on my server, the basketball starts at something like (0, 12, 0) and falls when the game first loads, bounces a couple times, and settles at (0, 0.5, 0). On the client, the ball just sticks at (0, 12, 0); I'm thinking that the ball reaches its "settled" position before the client has a chance to connect/receive snapshots, so it doesn't receive ball updates.

    Is there currently a way to force an object/entity to be constantly updated over the network?