Comments (13)
Let's do it. Do we have a relevant section in the manual? Should it go to UI section? Wouldn't you mind creating a PR, maybe just simply summarising the subject?
from stride.
Thank you. Let's put it under Physics. I will assist with the rest, I can check with others if it is the right location. Also, you can just dump content to the new docs page, and I can align and format further, just to save your time :)
from stride.
Oh, its it the bad jitter in the FPS tempalte? whenever you move around and look at something it looks like bad FPS?
from stride.
So I'm new to stride so I haven't use any other template, but yes - especially when you strafe right or left and move your mouse to keep looking at an object - you get horrible screen tearing. In fullscreen mode, you don't get it at all.
EDIT: Just pulled up the third person template - also get the screen tearing. Although, its less noticeable because of how the camera moves.
from stride.
Ok, assuming I understand what the problem is this time lol I have dealt with the same issue. It had to do with the Camera being directly attached in some way to the Physics body and updating its transforms based on that update interval.
The way I fixed it was the below steps:
What I had to do was create a SmoothFollowAndRotate script that just lerped between 2 entities at a certain speed.
[ComponentCategory("Utils")]
[DataContract("SmoothFollowAndRotate")]
public class SmoothFollowAndRotate : SyncScript
{
public Entity EntityToFollow { get; set; }
public float Speed { get; set; } = 1;
public override void Update()
{
var deltaTime = (float)this.Game.UpdateTime.Elapsed.TotalSeconds;
var currentPosition = Entity.Transform.Position;
var currentRotation = Entity.Transform.Rotation;
EntityToFollow.Transform.GetWorldTransformation(out var otherPosition, out var otherRotation, out var _);
var newPosition = Vector3.Lerp(currentPosition, otherPosition, Speed * deltaTime);
Entity.Transform.Position = newPosition;
Quaternion.Slerp(ref currentRotation, ref otherRotation, Speed * deltaTime, out var newRotation);
Entity.Transform.Rotation = newRotation;
}
}
Then in your scene you have to unparent the camera from the player controller and add that smooth follow and rotate component to follow a new pivot point on your character controller.
This will break things in certain scripts since they use direct references to a CameraComponent but I will list the fixes below.
PlayerInput.cs
change
public CameraComponent Camera { get; set; }
to
public Entity Camera { get; set; }
Utils.cs
change
CameraComponent camera
to
Entity camera,
and change
camera.Update();
var inverseView = Matrix.Invert(camera.ViewMatrix);
to
var inverseView = camera.Transform.WorldMatrix;
FpsCamera.cs
Remove
/// <summary>
/// Gets the camera component used to visualized the scene.
/// </summary>
private Entity Component;
and change
private void UpdateViewMatrix()
{
var camera = Component;
if (camera == null) return;
var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
Entity.Transform.Rotation = rotation;
}
to
private void UpdateViewMatrix()
{
var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
Entity.Transform.Rotation = rotation;
}
from stride.
Thank you for all of this, looks like you accidently copied and paste twice here, mind if you correct it? I got the rest of the changes in.
and change
private void UpdateViewMatrix()
{
var camera = Component;
if (camera == null) return;
var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
Entity.Transform.Rotation = rotation;
}
to
private void UpdateViewMatrix()
{
var camera = Entity;
if (camera == null) return;
var rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, 0);
Entity.Transform.Rotation = rotation;
}
from stride.
Ah yep, fixed!
Also worth mentioning that my best speed for for the follow script is 25, seems to be the smoothest without falling behind.
from stride.
Whoa. Well, I think I definitely screwed it up somewhere because I'm getting wild behavior.
I'm going to come back tonight and just rewrite the camera and movement system, while taking in your smooth lerping technique into account. For me, I think the player control and camera should all be in one script. Thanks a ton for the help! If you have a sample project with these changes let me know as well.
Sounds like this is probably not a v-sync issue.
from stride.
Here is the project with the fixes included: https://github.com/Doprez/smooth-fps-template/tree/main
It also had a change with some light shafts that cause an initial lag on loading the game but it should clear up after 2-3 seconds.
from stride.
@Doprez You are a saint! That fixed it. It was a bit laggy at first, but then when I also set the MinimumElapsedTime
to Zero - it became butter smooth, and the experience is now identical to fullscreen mode. This really should be the new FPS 1st person template too, its much much smoother.
Its full steam ahead for my wpf/avalonia overlay. I think I definitely will open source it. The other wpf/avalonia solutions involve the attempt of rendering the UI framework in Stride, mine just uses win32 apis to get it to work.
EDIT: The only thing not working in this code is that gun shots do not hit when you are moving the character, I'm sure i can figure out a fix to that though.
from stride.
@Doprez, do we need to document this?
from stride.
@Doprez, do we need to document this?
Probably wouldnt hurt, I know this isnt the first time I have seen someone with this issue and even when I first started this drove me nuts because I didnt know why lol.
from stride.
Yep, I can take some time later to do this. I am not sure where would be the right spot though.. maybe Physics?
from stride.
Related Issues (20)
- Stride 4.2 built in Code Editor not able to find assemblies or defenitions HOT 1
- Crash and Error HOT 3
- I would like the Stride engine to provide a 2D tilemap system. HOT 1
- Opening Settings causes Game Studio to crash HOT 12
- [Community Toolkit] iOS Bug: "System.DllNotFoundException, Message=freetype" - What does this mean? Any fix? HOT 1
- [Community Toolkit] Android Bug: "ReferencePath" does not define a value for metadata "CopyLocal" - Any thoughts or solutions? HOT 5
- Multiple Projects require Module class if they reference eachother. HOT 5
- Preliminary progress on Stride-Maui integration ... What is a good workflow to follow from here? HOT 5
- Game Will Not Launch if PublishSingleFile is Enabled HOT 3
- Importing files can cause crash depending on project architecture HOT 2
- Model importer regression in master HOT 15
- Vulkan/OpenGL error generating vert and frag files HOT 1
- iOS Projects Fail to Build
- Add a select type component (like html select or a dropdownmenu) component available to use in between the list of tools components
- Add some new "input type" and other additional options for EditText
- Add a datetimepicker HOT 2
- Button in VisualStudio to open the GameEditor HOT 2
- Better Mod Support
- About link for Third Party Software is wrong for OpenTK HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stride.