Comments (2)
I'm not sure if PhysX lib we use for physics simulation provides such information.
from flaxengine.
If physx doesn't allow for that, could you implement it yourself?
I used this code to implement the sliding behaviour myself (following a youtube guide that is ^^)
`private void HandleSlopeSlidingCapsuleCast()
{
// length needed to hit the ground even when on very steep surface - might need to change if it's not working correctly everyhwere
float tracelength = (75f/2f)+10f;
if(Physics.CapsuleCast(Actor.Position, 75f, 0f, Vector3.Down, out RayCastHit hit, Quaternion.Euler(Vector3.Zero), tracelength, TerrainCollisionLayer, false))
{
//Debug.Log("Ground detected!");
//BoundingSphere b;
//b.Center = hit.Point;
//b.Radius = 5;
//DebugDraw.DrawSphere(b, Color.Red, 1f);
float angle = Vector3.Angle(hit.Normal, Vector3.Up);
//Debug.Log("Angle of ground: " + angle);
if(angle > 45f)
{
//Debug.Log("We should slide now!");
slopeSlideVelocity = Vector3.ProjectOnPlane(new Vector3(0, yVelocity, 0), hit.Normal);
// NOTE: i was looking for a way to make the sliding go faster. just multiplying the velocity
// seems to do the trick just fine ^^
// UPDATE: multiplaying the Y component led to the char seemingly jumping higher. removing it
// got me to the desired effect.
slopeSlideVelocity.X *= 2;
slopeSlideVelocity.Z *= 2;
return;
}
}
// fade out sliding instead of instant stop as long as we have a certain speed. deactivate this part to get instant stop.
// NOTE: however, this will still result in the char being pushed away from slope he walked onto.
if(isSliding)
{
slopeSlideVelocity -= slopeSlideVelocity * Time.DeltaTime * 12;
if(slopeSlideVelocity.Length > 50)
{
return;
}
else
{
// need this here to one-time after sliding re-enable player input
MovementProhibited = false;
}
}
if(slopeSlideVelocity != Vector3.Zero)
{
slopeSlideVelocity = Vector3.Zero;
MovementProhibited = false;
}
}`
It will remove player control and then slide down a slope that is detected beneath the player. The problem with this is, as you can see from the NOTE in there, if the player just walks onto a slope that would result in sliding, he first walks onto it, then gets pushed back. I think this is because this movement i manually add clashes with the normal movement of the engine?
When set to prevent climbing + force sliding without my custom code, the character would just not step on that slope to begin with. Would it be possible to implement this kind of code on the engine level to prevent that pushback?
Also kind of weird that PhysX would not expose that information, but I don't know much about it so this i just me wondering how other engines with physx do that kind of thing then ^^
from flaxengine.
Related Issues (20)
- Camera projection default viewport missmatch
- [Suggestion] Add option to chose prefab root actor class when create it from content folder menu HOT 1
- A way to exit ui editor mode in prefab editor
- Support for Animating skeleton bones HOT 2
- [Proposal] Change default tool hotkeys to industry standard WER
- The sprite's names doesn't update after change in sprite atlas
- Pasting previously copied sprites does not work in sprite atlas
- Render actor icons in viewport at constant size HOT 4
- Add Video backend for Linux HOT 3
- [Suggestion] Directional Light Cookie
- [Suggestion] Render Texture Asset Type HOT 1
- QoL - Consistent unit of measurement on character controller
- Importing normals of fbx meshes done in Blender 4.x broken HOT 1
- TextBox: Wrong text highlights with center and far horizontal alignment
- [ Feature Request ] Add option to apply specific change on prefab HOT 1
- [Suggestion] Material Function Input Ordering
- Third-Party Libraries Failing to Load Assemblies in Cooked Game HOT 1
- Adding a newline into a `[Header]` attribute cuts off the displayed text
- Issues with selecting a csg brush in the viewport
- EXR file import crashes the editor
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 flaxengine.