#StackBounty: #unity #physics #collider Changing CharacterController's height causes jittering issue in Unity

Bounty: 50

As title said changing height of Character Controller causes jittering issue.

For example when I reduced the height of CharacterController, it seems CharacterController was floating at each frame and it keeps falling to the ground. Opposite situation has same issue, different is collider is actually already passing the ground so it just push up the object by physics engine.

(I saw some similar issue with Terrain, in this case it’s worse, it just falling through the terrain)

Anyway someone told that I have to change center of CharacterController too, with foot offset(I don’t know what exactly that is), so I tried to change the center of CharacterController when resizing height but it still have same problem, nothing different.

This is the code that I’m using:

void Update() {
    if(Input.GetKeyDown(KeyCode.LeftControl)) {
        isCrouched = !isCrouched;
    }

    float newHeight = isCrouched ? crouchingHeight : originalHeight;
    controller.height = Mathf.Lerp(controller.height, newHeight, Time.deltaTime * smooth);

    Vector3 newCenter = isCrouched ? new Vector3(0, 0.2f, 0) : Vector3.zero;
    controller.center = Vector3.Lerp(controller.center, newCenter, Time.deltaTime * smooth);

    float newCamPos = isCrouched ? origCamPos.y - 0.2f : origCamPos.y;
    Vector3 newPos = new Vector3(cam.localPosition.x, newCamPos, cam.localPosition.z);

    cam.localPosition = Vector3.Lerp(cam.localPosition, newPos, Time.deltaTime * smooth);
}

Is there a way to rid off that jittering issue while changing height of Character Controller? Any advice will very appreciate it.


Get this bounty!!!

#StackBounty: #unity #unity-networking Enter in a match that is already started

Bounty: 50

In my Unity mobile game, I need multiplayer online functionalities. All the players should be visible in the world at any given time (of course, with some filtering), and a player should be able to connect at any time. Let’s say that, for the purpose of this question, only 100 players at the time will log into the game.

My first try involved using Unity’s built-in NetworkManager, but the two problems that arose are that:

  1. One player is always the host, meaning that if that player logs out all the other players.
  2. I did not manage to make it work on two different networks.

The implementation I used comes from this tutorial.

Next try was using an extension of NetworkLobbyManager, that allows through the Matchmaking system to solve problem 2.

This is my implementation:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using UnityEngine.SceneManagement;

public class AutoLobbyManager : NetworkLobbyManager {

    protected int currentPage = 0;
    protected int previousPage = 0;

    public void CreateOrJoin() {
        StartMatchMaker();
        RequestPage(0);
    }

    public void OnMatchListReceived(bool success, string extendedInfo, List<MatchInfoSnapshot> matches)
    {
        if (matches.Count == 0) {
            // Server does not exist yet. Create one.
            CreateMatch();
            return;
        } 

        // There is then a server. Join it.
        JoinMatch(matches[0]);


    }

    public void RequestPage(int page) {
        matchMaker.ListMatches(page, 1, "", true, 0, 0, OnMatchListReceived);
    }


    public void CreateMatch() {
        matchMaker.CreateMatch( "Main Match", (uint)maxPlayers, true, "", "", "", 0, 0, OnMatchCreate);
    }


    void JoinMatch(MatchInfoSnapshot match) {
        matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, OnMatchJoined);
    }


    public override void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) {
        base.OnMatchCreate(success, extendedInfo, matchInfo);
        Debug.Log("Match created!");
        ServerChangeScene(playScene);
    }

     public override void OnClientSceneChanged(NetworkConnection conn) {
         string loadedSceneName = SceneManager.GetSceneAt(0).name;
         if (loadedSceneName == lobbyScene) {
           if (client.isConnected)
               CallOnClientEnterLobby();
         } else {
           CallOnClientExitLobby();
         }

         OnLobbyClientSceneChanged(conn);
    }

    void CallOnClientEnterLobby() {
        OnLobbyClientEnter();
        foreach (var player in lobbySlots)
        {
            if (player == null)
                continue;

            player.readyToBegin = false;
            player.OnClientEnterLobby();
        }
    }

    void CallOnClientExitLobby() {
        OnLobbyClientExit();
        foreach (var player in lobbySlots)
        {
            if (player == null)
                continue;

            player.OnClientExitLobby();
        }
    }

}

This makes possible to create a Lobby if there is no Lobby, and join the first if there is. It works, if we remove the highlighted line here:

public override void OnMatchCreate(bool success, string extendedInfo, 
MatchInfo matchInfo) {
    base.OnMatchCreate(success, extendedInfo, matchInfo);
    Debug.Log("Match created!");
    ***** ServerChangeScene(playScene); *****
}

Because this starts the game. If that line is activated (since I want to start the game as soon as possible), when a client tries to connect, the Server logs:

NetworkLobbyManager can't accept new connection [hostId: 0 connectionId: 1 isReady: False channel count: 2], not in lobby and game already in progress.

And the client is not added to the game. I understand that lobbies usually work like that, but:

1. Is it possible to add a client after a game is added, with NetworkLobbyManager?

2. Is it the right approach to achieve a multiplayer, non-lobby-based, non-host-based, online game in Unity?


Get this bounty!!!

#StackBounty: #unity #physics #collider Changing CharacterController's height causes jittering issue in Unity

Bounty: 50

As title said changing height of Character Controller causes jittering issue.

For example when I reduced the height of CharacterController, it seems CharacterController was floating at each frame and it keeps falling to the ground. Opposite situation has same issue, different is collider is actually already passing the ground so it just push up the object by physics engine.

(I saw some similar issue with Terrain, in this case it’s worse, it just falling through the terrain)

Anyway someone told that I have to change center of CharacterController too, with foot offset(I don’t know what exactly that is), so I tried to change the center of CharacterController when resizing height but it still have same problem, nothing different.

This is the code that I’m using:

void Update() {
    if(Input.GetKeyDown(KeyCode.LeftControl)) {
        isCrouched = !isCrouched;
    }

    float newHeight = isCrouched ? crouchingHeight : originalHeight;
    controller.height = Mathf.Lerp(controller.height, newHeight, Time.deltaTime * smooth);

    Vector3 newCenter = isCrouched ? new Vector3(0, 0.2f, 0) : Vector3.zero;
    controller.center = Vector3.Lerp(controller.center, newCenter, Time.deltaTime * smooth);

    float newCamPos = isCrouched ? origCamPos.y - 0.2f : origCamPos.y;
    Vector3 newPos = new Vector3(cam.localPosition.x, newCamPos, cam.localPosition.z);

    cam.localPosition = Vector3.Lerp(cam.localPosition, newPos, Time.deltaTime * smooth);
}

Is there a way to rid off that jittering issue while changing height of Character Controller? Any advice will very appreciate it.


Get this bounty!!!

#StackBounty: #unity #physics #collider Changing CharacterController's height causes jittering issue in Unity

Bounty: 50

As title said changing height of Character Controller causes jittering issue.

For example when I reduced the height of CharacterController, it seems CharacterController was floating at each frame and it keeps falling to the ground. Opposite situation has same issue, different is collider is actually already passing the ground so it just push up the object by physics engine.

(I saw some similar issue with Terrain, in this case it’s worse, it just falling through the terrain)

Anyway someone told that I have to change center of CharacterController too, with foot offset(I don’t know what exactly that is), so I tried to change the center of CharacterController when resizing height but it still have same problem, nothing different.

This is the code that I’m using:

void Update() {
    if(Input.GetKeyDown(KeyCode.LeftControl)) {
        isCrouched = !isCrouched;
    }

    float newHeight = isCrouched ? crouchingHeight : originalHeight;
    controller.height = Mathf.Lerp(controller.height, newHeight, Time.deltaTime * smooth);

    Vector3 newCenter = isCrouched ? new Vector3(0, 0.2f, 0) : Vector3.zero;
    controller.center = Vector3.Lerp(controller.center, newCenter, Time.deltaTime * smooth);

    float newCamPos = isCrouched ? origCamPos.y - 0.2f : origCamPos.y;
    Vector3 newPos = new Vector3(cam.localPosition.x, newCamPos, cam.localPosition.z);

    cam.localPosition = Vector3.Lerp(cam.localPosition, newPos, Time.deltaTime * smooth);
}

Is there a way to rid off that jittering issue while changing height of Character Controller? Any advice will very appreciate it.


Get this bounty!!!

#StackBounty: #unity #physics #collider Changing CharacterController's height causes jittering issue in Unity

Bounty: 50

As title said changing height of Character Controller causes jittering issue.

For example when I reduced the height of CharacterController, it seems CharacterController was floating at each frame and it keeps falling to the ground. Opposite situation has same issue, different is collider is actually already passing the ground so it just push up the object by physics engine.

(I saw some similar issue with Terrain, in this case it’s worse, it just falling through the terrain)

Anyway someone told that I have to change center of CharacterController too, with foot offset(I don’t know what exactly that is), so I tried to change the center of CharacterController when resizing height but it still have same problem, nothing different.

This is the code that I’m using:

void Update() {
    if(Input.GetKeyDown(KeyCode.LeftControl)) {
        isCrouched = !isCrouched;
    }

    float newHeight = isCrouched ? crouchingHeight : originalHeight;
    controller.height = Mathf.Lerp(controller.height, newHeight, Time.deltaTime * smooth);

    Vector3 newCenter = isCrouched ? new Vector3(0, 0.2f, 0) : Vector3.zero;
    controller.center = Vector3.Lerp(controller.center, newCenter, Time.deltaTime * smooth);

    float newCamPos = isCrouched ? origCamPos.y - 0.2f : origCamPos.y;
    Vector3 newPos = new Vector3(cam.localPosition.x, newCamPos, cam.localPosition.z);

    cam.localPosition = Vector3.Lerp(cam.localPosition, newPos, Time.deltaTime * smooth);
}

Is there a way to rid off that jittering issue while changing height of Character Controller? Any advice will very appreciate it.


Get this bounty!!!

#StackBounty: #ubuntu #vnc #unity Access default unity desktop only over VNC connection

Bounty: 50

I installed Unity desktop on my cloud instance (18.04.1 x64)

sudo apt-get install ubuntu-desktop

and the VNC Server

sudo apt-get install vnc4server

What would be the contents of .vnc/xstartup file to invoke Unity desktop on a connection. I know for Gnome, its something like this :

unset SESSION_MANAGER
metacity &
gnome-settings-daemon &
gnome-panel &

But what about Unity? I only need it to be invoked over VNC connection, rest of the time GUI shouldn’t be taking up resources. Possible?

Help would be appreciated.


Get this bounty!!!

#StackBounty: #unity #18.04 #menu #evince evince menus missing/scattered

Bounty: 50

Recently, the evince menus in the unity global menu bar have mostly gone missing on both my desktop and my laptop. Currently, there is only one pretty useless menu, “Document Viewer”, in that bar.

I found the “missing” menu items behind some of the symbols in the top left or top right of the evince windows (not within the unity global menu bar, but just below it when the evince window is maximised).

However, I would prefer to have all the menus in one place, in the menu bar, as text. Is it possible to restore this behaviour? If so, how?

I found this (old) related question describing a similar problem: Unity Global Menu Integration missing for some programs but the packages mentioned in the answer seem to have been superseded by the *unity-gtk* packages, which are installed.


Get this bounty!!!

#StackBounty: #unity #lighting Moving directional light cause huge fps drop: why?

Bounty: 50

I’ve implemented a simple script to simulate Sun Rotation (day/night cycle).

In my “Update” i Rotate main Directional Light (the sun).
What i’ve noticed is that my FPS dropped from 60 to 20-25 fps.

I can understand why: recalculate all light each frame can be (euphemism) cpu-consuming.

So i switched approach using an InvokeRepeating with a repeating time of 0.25f seconds (4 “movement” per second).

Also with this approach my frame rate drop from 60 to 50 (unacceptable).

So my question is : is there a way to move/rotate a light (simulating a day/night cycle for instance) without meet a so big fps-dropping but mantaining realism ?

Thanks


Get this bounty!!!

#StackBounty: #unity #keyboard #monitor #multimedia #gnome-power-manager How to use keyboard keys without ending IDLE_MODE_BLANK?

Bounty: 50

I want to change the volume without waking my laptop display up.

This question wants to accomplish the same but has no usable answer (turning it off again is not an option as the environment is light-sensitive, the display has to stay off the entire time)

As display wakeup seems to be managed by gnome-power-manager I read this
which pointed me at IDLETIME
which seems to be managed by gnome-idle-monitor….
which left me without leads as my C is too bad.


So to summarize: I want to be able to use some specific keys on my keyboard (e.g. volume keys) without resetting the IDLETIME counter ->
resulting in gnome not waking up my display)

How can I accomplish this?


Update: I don’t care about the way (preventing IDLETIME reset / some other obscure dark magic), for me only the result – display staying off – matters.


Get this bounty!!!

#StackBounty: #unity #shaders #unity-shader-graph Unity LWRP & Projection Shader

Bounty: 50

I recently added the Lightweight Render Pipeline to my project as I’d like to start experimenting with Shadergraph to see if I can get a better basic understanding of shaders.

Everything has gone pretty smoothly except the Shader used by my Projectors, the Projection Shader Standard asset no longer works (does not project the texture) and I have very little experience with Shaders.

The main concern for me is that I cannot find anyone else who seems to be having this problem.

I have tried reading through the older shader and recreating it in ShaderGraph but I’m out of my depth.

So could anyone provide me with a simple projection shader or materials on where I could learn to write one, or just learn more about them projection specifically.

thanks

edit: To clarify I was using the Projectors to project a simple square texture on to each tile that I could tint, to show selectable/current/target tiles.
Picture of Old Setup

Old shader that no longer works under Lightweight Render Pipeline From DevGuy @ Unity Forums

// Upgrade NOTE: replaced '_Projector' with 'unity_Projector'
// Upgrade NOTE: replaced '_ProjectorClip' with 'unity_ProjectorClip'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

  Shader "Projector/AdditiveTint" {
     Properties {
       _Color ("Tint Color", Color) = (1,1,1,1)
       _Attenuation ("Falloff", Range(0.0, 1.0)) = 1.0
       _ShadowTex ("Cookie", 2D) = "gray" {}
     }
     Subshader {
       Tags {"Queue"="Transparent"}
       Pass {
         ZWrite Off
         ColorMask RGB
         Blend SrcAlpha One // Additive blending
         Offset -1, -1

         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
         #include "UnityCG.cginc"

         struct v2f {
           float4 uvShadow : TEXCOORD0;
           float4 pos : SV_POSITION;
         };

         float4x4 unity_Projector;
         float4x4 unity_ProjectorClip;

         v2f vert (float4 vertex : POSITION)
         {
           v2f o;
           o.pos = UnityObjectToClipPos (vertex);
           o.uvShadow = mul (unity_Projector, vertex);
           return o;
         }

         sampler2D _ShadowTex;
         fixed4 _Color;
         float _Attenuation;

         fixed4 frag (v2f i) : SV_Target
         {
           // Apply alpha mask
           fixed4 texCookie = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
           fixed4 outColor = _Color * texCookie.a;
           // Attenuation
           float depth = i.uvShadow.z; // [-1 (near), 1 (far)]
           return outColor * clamp(1.0 - abs(depth) + _Attenuation, 0.0, 1.0);
         }
         ENDCG
       }
     }
  }


Get this bounty!!!