Sphere Rigidbody visual oddities when moving at fast speeds & distances
When testing my Unity game on Xbox One I am getting a very large amount of visual "jitter" from the ball. This is a skeeball game where you control the movement of the ball. Essentially the core of the movement is similar to the Rollerball tutorials. On PC this works fine and there are no perceptible jitters. However, on Xbox, I am seeing this a lot more. The object is travelling large distances with the camera following smoothly behind. None of the other objects or scenery are affected, I actually think the camera itself is moving perfectly. But, the ball itself seems to glitch.
I double checked to make sure that controller input is checked in "Update", physics/addForce are adjusted in "Fixed Update" and the camera follow movement is adjusted in "LateUpdate".
The ball object has a sphere rigidbody and I am using AddForce to apply movement.
I'll try to see if I can capture some video of this happening, but since it mainly occurs on the Xbox that may be difficult. The best explanation I can give is that while flying through the air, the ball will hiccup and appear visually to jump slightly in any direction, but the physics and velocity don't change or anything, I think this really is just a visual issue. It doesn't happen as much for smaller movements, but the fast speed / long distance movements cause all sorts of trouble.
Thanks! Nick
Could you post your code or a gif of the glitch happening?
@n314p - Haven't figured out how to easily record from the Xbox One but have them available elsewhere, and the Windows 10 store doesn't display the game previews. If you have Xbox One, search for Extreme Skeeball in the Creators Collection group and check out any of the game captures on the Iceberg level. That is the level where it is most visible.
It's a big scene, and technically the ball is covering a pretty big distance while the camera is following it.
Otherwise, is there a way to access Xbox One game recordings outside of Xbox One? It seems strange that they don't show up in the store... I'll see if I can record my own game capture and upload it to OneDrive or something like that, I think I remember seeing that option somewhere...
If someone can help me figure it out, I'll send a free game code their way! :)
Here is a screen recording from the Xbox. The visual glitch is pretty noticeable. YouTube Link
Starting to think this is some weird update/fixedupdate/vsync issue... Here is some of my code from the skeeball object. I have tried the three vsync options, and I have tried to use fixedDeltaTime in the FixedUpdate function, but I still seem to have the same problem. Frame rate is generally between 150-200 when this happens.
function Update()
{
moveHorizontal = Input.GetAxis("Horizontal");
moveVertical = Input.GetAxis("Vertical");
movement = new Vector3(moveHorizontal, 0.0, moveVertical);
}
//PHYSICS $$anonymous$$OVE$$anonymous$$ENT
function FixedUpdate()
{
if(playerInAir == false)
{
GetComponent.<Rigidbody>().AddForce(movement * moveSpeed * Time.deltaTime);
my$$anonymous$$agnitude = GetComponent.<Rigidbody>().velocity.magnitude;
rollingSound.volume = .5 * my$$anonymous$$agnitude;
}
else if (playerInAir == true)
{
GetComponent.<Rigidbody>().AddForce((movement * moveSpeed * Time.deltaTime) * moveSpeedInAir);
my$$anonymous$$agnitude = GetComponent.<Rigidbody>().velocity.magnitude;
rollingSound.volume = 0;
}
my$$anonymous$$agnitude = GetComponent.<Rigidbody>().velocity.magnitude;
velocityText.text = my$$anonymous$$agnitude.ToString("00");
windSound.volume = .5 * my$$anonymous$$agnitude;
}
I've got some other items in here to adjust a wind sound, but taking those out didn't seem to have any effect.
Just the standard smooth camera follow from Unity:
using UnityEngine;
using System.Collections;
public class CameraFollow : $$anonymous$$onoBehaviour
{
public Transform target; // The position that that camera will be following.
public float smoothing = 4f; // The speed with which the camera will be following.
Vector3 offset; // The initial offset from the target.
void Start()
{
// Calculate the initial offset.
offset = transform.position - target.position;
}
void LateUpdate()
{
// Create a postion the camera is ai$$anonymous$$g for based on the offset from the target.
Vector3 targetCamPos = target.position + offset;
// Smoothly interpolate between the camera's current position and it's target position.
transform.position = Vector3.Lerp(transform.position, targetCamPos, smoothing * Time.deltaTime);
}
}
This is pointing at the player transform.
I have gone back through and optimized a few things (I shouldn't have been calling GetComponent so many times, and I reduced some detail in things like the ocean water) and I think that has helped, but it still seems to be happening slightly on the PC. Like I mentioned earlier I am already getting O$$anonymous$$ framerates, so I don't think that is the issue. I'm building my changes for Xbox and will see if it got any better.