Comments (8)
Use friction on the body/shape
from chipmunk2d.
@aismann if you mean to set friction on the player's body shape, I tried that, but it didn't have any effect. I am using cpBodyApplyImpulseAtLocalPoint
to apply the impulse and make the player move, am I doing it wrong?
from chipmunk2d.
Let me See the source snippet plz
or look on the manual:
cpFloat cpShapeGetFriction(const cpShape *shape)
void cpShapeSetFriction(cpShape *shape, cpFloat value)
Friction coefficient. Chipmunk uses the Coulomb friction model, a value of 0.0 is frictionless. The friction for a collision is found by multiplying the friction of the individual shapes together. Tables of friction coefficients.
from chipmunk2d.
@aismann I pushed my testing application here so you can check:
https://github.com/VictorQueiroz/Chipmunk2D-TopDown-Test
from chipmunk2d.
@VictorQueiroz
I think cpShapeSetFriction() is only working sliding on other shapes. My mistake.
from chipmunk2d.
@aismann what is the alternative to achieve what I want?
from chipmunk2d.
@aismann here is the video you asked:
from chipmunk2d.
I finally made it. I updated the project I sent you on GitHub. A comment from a guy in Reddit helped me fix it:
I can't read c++ very well, but from what you describe it sounds like you haven't implemented drag yet. I like to implement it like this:
velocity = velocity - (velocity * 0.25 * time.deltaTime)
Velocity in this case is the movement vector of your object. You just lower it by a percentage per second until the movement is so little that it's basically stopped. However, it is good to note that it will never actually stop like this.
You could implement drag a different way, it's really up to your preference.
I gently set it's velocity on every frame:
cpVect vel = cpBodyGetVelocity(body.playable->controlBody);
vel = vel - (vel * 0.25 * dt);
cpBodySetVelocity(body.playable->controlBody, vel);
from chipmunk2d.
Related Issues (20)
- [Documentation] cpPolyShapeGetCount typo in docs
- Licensing confusion HOT 1
- cpSpaceSegmentQueryFirst returns wrong normal If a segment query starts within a shape
- Leaking memory on sleeping bodies
- Can new version tag be released including the sys/sysctl.h related fix? HOT 1
- Reproducable state & serialization of space
- Stackoverflow in SubtreeInsert when adding too many shapes to a space.
- Demo crashing in release mode [using GCC 13] HOT 5
- Segment query first, sometimes failing HOT 9
- The demo crashes whether it's built with gcc or visual studio HOT 3
- Perf improvements HOT 5
- Add constraint between two static bodies which are later changed to dynamic does not work HOT 5
- Freezes when static body collides HOT 5
- Assessment of the difficulty in porting CPU architecture for chipmunk2D HOT 2
- Crash in debug mode using MSVC 2022 HOT 1
- Collisions and sleep HOT 1
- Is there a reason why maxForce doesnt apply to DampedSpring and DampedRotarySpring?
- Is there formatting config/rules used on Chipmunk2D? HOT 2
- Total impulse of cpDampedRotarySpring is wrong, it adds the damping instead of subtracting it.
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 chipmunk2d.