Construct 3 3D Physics
Note versions 2.x.x are based around the rapier physics engine. Use only examples with 'Rapier' in the filename.
In demo above click mouse to do raycast, create another 3DShape at the raycast hit point and apply a little impulse force.
To further support development:
- 3D Shape: Box, Wedge, Corner-in, Corner-out, Prism, Pyramid
- 3D Object: Capsule, Box, Cylinder, Sphere collider around 3D Object
- Only z axis rotation (3D Shape supports other rotation with the rotate 3d behavior or 3D Object without rotate 3d behavior)
- Apply impulse (and towards position)
- Immovable / movable
- World gravity setting
- 3D raycast with group filter
- Set mass
- Set velocity
- Set linear, angular damping
- Set collision filter group/mask
- Apply force (and towards position)
- Apply torque
- Support 3DShape full 3D rotation using Rotate 3D Behavior.
- Add Trigger for raycastResult available
- Add expression for x,y,z velocity
- Physics engine runs in worker to offload main runtime thread CPU
- Kinematic Character Controller
- Spherical joint
- Trimesh collider for Sprite with Mesh
Open to feedback and development collaboration for future rev share, leave comments or contact me on C3 Community Discord (@mikal1464)
Near term future work
[Rapier] 3D Object support (fixed box collider first, others later)[Rapier] Add heightfield for sprite w/ mesh[Rapier] Collision group/filter
[Rapier] OnCollision trigger[Rapier] CollisionData (from the OnCollision trigger)Add Trigger for raycastResult available (synchronous now anyway, but future may be async)Apply impulse towards position- Detect runtime changes of C3 object size and update physics body.
HeightfieldAdd expression for x,y,z velocity
More 3D Shape shapescorner-in, corner-out, pyramid, prism
Support 3DShape full 3D rotation using Rotate 3D Behavior.
Disable collisions on body (use collision filter group/mask)
More raycast options (array of all objects hit,collision filterGroup and mask, skipface), raycast to a particular body (probably identified by UID)Collision filterGroups and masksApply force
Apply torque
Usage Notes:
Worker mode
- Do not enable the C3 project setting 'Use worker'. Explicitly change the setting to 'no', do not leave as 'auto'.
- Setting 'Use worker' to 'yes' breaks one of the libraries being used 'comlink' and will show up as cast ray and cast shape no longer working. I will look for a work around in the future.
3D Shape
- Natively 3D Shape only supports Z axis rotation, physics will do the same.
- To implement full 3D rotation for 3D Shape (including physics) add the free Rotate 3D behavior to 3DShape.
- With both behaviors used together, the Z angle can still be overridden by C3 behavior and ACEs and the X,Y rotation will be controlled by physics.
3D Object
- Natively supports x,y,z rotation. Do not add Rotate 3D behavior
- Specify collider abstraction to be used with 3D Object (Capsule, Box...)
Performance
- Use collision filter group and mask to limit the number of collision checks. For example in a platformer, immovable terrain does not need to be able to collide with itself. See the suggestions in the collisioFilter.txt file from Foozle.
- Also use filter group and mask with with raycast if it is used often.
Example rayacastExample-mouselook courtesy of: Fodi
For character control see the project example: RapierKinematicCharacter.c3p
For more implementations, look at other 'Rapier' project examples.
For general concepts, this addon is a small subset of the Rapier physics js library functionality.
For more information and general concepts of the Rapier library, see:
- https://rapier.rs/docs/user_guides/javascript/rigid_bodies
- https://rapier.rs/docs/user_guides/javascript/colliders
- https://rapier.rs/docs/user_guides/javascript/joints
- https://rapier.rs/docs/user_guides/javascript/character_controller
- https://rapier.rs/docs/user_guides/javascript/scene_queries
- https://rapier.rs/docs/user_guides/javascript/common_mistakes
Note versions 2.x.x use an experimental rapier physics engine with limited features. Use only examples with 'Rapier' in the filename.
Updated | 13 days ago |
Status | In development |
Category | Assets |
Rating | Rated 5.0 out of 5 stars (4 total ratings) |
Author | kindeyegames |
Made with | Construct |
Tags | construct-3 |
Purchase
In order to download this asset pack you must purchase it at or above the minimum price of $5 USD. You will get access to the following files:
Development log
- (feat) Add sensor support for character controller collisions13 days ago
- Add model mesh - courtesy of Foozle21 days ago
- Add On physics ready trigger45 days ago
- Add shape cast thanks to Foozle!45 days ago
- Add simpler raycast example project53 days ago
- Add revolute joint ACE54 days ago
- [breaking change] add filter groups to raycast61 days ago
- fix (collisions) fix collision filter group ACEs96 days ago
Comments
Log in with itch.io to leave a comment.
Applying force behaving unexpectedly on new versions. I applied 10 force on my object and it keeps on going even I have release the keys.
Force in physics is something continuously applied. An example of a force is gravity or a rocket thruster continuously on.
If you want to stop the force you must set it to 0.
If you want a brief 'push' use an impulse instead.
Thanks !
but when I Apply impulse it start to rotate alot
impulse 1,0,0 to relative 0,0,0
Apply some rotational damping. Is 0,0,0 the center of your object? Or is it not 'balanced'?
Send an example project and I can test.
Sure
https://drive.google.com/file/d/1OTRXqcqErSdYhz7SkbB9jV5HqTB3iWPY/view?usp=shari...
hello. where to see examples of using physics with a character? is there any documentation on the physics plugin? it is absolutely not clear how it is organized here.
For character see the project example: RapierKinematicCharacter.c3p
For more implementations, look at other 'Rapier' project examples.
For general concepts, this addon is a small subset of the Rapier physics js library functionality.
For more information and general concepts of the Rapier library, see:
Hi,
the Raycast results always seem to return HitFaceIndex: 0 regardless of which side of the 3Dshape has been hit. Is this a bug or am I missing something?
This plugin is ace, please keep up the good work!
Cheers!
Ah, sorry the face id is not implemented. it was available in cannon, but I need to explore rapier for it.
RapierKinematicCharacter.c3p
RapierSimple-1.c3p
These 2 don't work for me. Black screen with this error for both. Using 2.11.0.
Thanks for the bug report and the screenshot, they helped me debug the issue.
Fixed:
https://kindeyegames.itch.io/construct-3-cannon/devlog/744425/fix-updaterender-f...
Love your work ! , ... RapierJointsNoLight says its not a valid c3p file ...
Hmm, are you using the latest version of the addon?
Yes
Try RapierJointsMinimal, pulled out some unused code.
that works ! thanks ! be blessed !
tho the physics body offsets with the 3D object sometimes
the translate character controller don't move, did i something wrong?
Nothing obvious in this snippet. Test the sample projects, check if you are using latest version. If you cannot find an error, share the project.
the samples projects work, but in my project don't work, the box don't move, i'm using construct 3 v385 beta, here the project file: https://drive.google.com/file/d/18-Gp63WhD-ycurQb8viBRaSq6tAD5_wA/view?usp=shari...
Try this:
https://sendgb.com/ydtu1l6ebiZ
Moved translate to every tick (to enable gravity, -10 to z). Change down to set x value. Add ground for character to move on. Also changed project to regular z instead of normalized z. Do not use normalized z for 3d project. Also sort based on camera distance for 3d layer (for 3d project).
it worked, but only when i put the ground with dynamic physic and turn on immovable, that wasn't clear lol, so the physic only work when you put one object with dynamics? put this in the description please , i was totaly lost until know this lol.
You don't need the ground, but for me it feels better to me to have a ground and some fake gravity for a kinematic character controller. You can delete the ground in my example and the 'D' movement still works (but it will be falling due to the fake gravity.)
For some more info about character controllers in general see: https://rapier.rs/docs/user_guides/javascript/character_controller
(This is the physics library embedded in this addon, a subset of the many features are exposed to C3 right now.)
theres is a way to change the directions of player relative to camera?
You can try setting the x,y,z translation to the camera view direction (see camera3d view direction), experiment with that.
I'm curious, I'm probably doing something wrong :P But I was just playing around and I couldn't seem to figure out how to make the dice react like dice, it sorta distorts when it rolls or moves around in any way.
Just curious what I'm doing wrong :P
My guess is you are using normalized Z instead of regular z in project settings (should always use regular z when doing 3d)
Thank you! That worked :) I had no idea that setting existed :P
this is real power plugin! it can help me creat a real world
greetings On the page with SSO effect, when the opacity of the object decreases, it becomes black
If I pledge a considerable amount of money, can you implement the following: 3D collider from 2D collision polygon (mesh), extruded on Z-Axis by a given z-height?
Do you really need the x,y grid to be variable? Otherwise, you can use the heightfield shape that was just added to sprite mesh - check it out.
https://kindeyegames.itch.io/construct-3-cannon/devlog/635793/add-heightfield-sh...
If heightfeild does not work, can you show some screencaps about what you are looking for? (Sadly the cannon-es trimesh shape is not fully implemented it doesn't collide with the majority of other shapes.)
I construct an extruded 3d object at runtime from a mesh-distorted tiled background (creating mesh-distorted tiled backgrounds per outer edge)
I need the sewn-together 3d frankenstein object to check against collisions and raycasts.
Can you provide a sample project with this geometry, so I can look in more detail and get a feeling for the scope (and how to do it, since the physics trimesh doesn't work.)
https://drive.google.com/file/d/1J1ERc4qsMEnviZXoH06LS_4_NvRxGHE_/view?usp=drive...
Dang - I don't have some of those addons. Can you make a project where they are bundled?
Try out the sprite trimesh support!
This will work! :D
Thank you so much!
is the ssao-1-5-1 addon the same as Mikal_SSAO_Color? some examples are telling me I need it. but I can't find it
Ah, they are different, if you have 3DObject, it is available there.
If you let me know which example(s) has it, I'll check and swap it out for the 1-5-1 version.
PhysicsAndRotate
spring and Raycast_Triggers can't open saying that it's not a valid c3c file
Added SSAO-1-6-0.c3addon, please try that (and latest physics addon and c3 beta) - for Raycast Triggers
Hey Mikal! So far I’m absolutely loving this addon. I’m trying to build a super simple first person 3D platformer template and I’m using the Set velocity action for moving the player around on the X/Y plane but I don’t want to set the Z velocity with this action. (My plan is to use Z impulses for jumping later).
Can you please add expressions for the Canon3DPhysics behaviour that just return the object’s current X/Y/Z velocity? Because then I could just set the Z velocity in this action to Self.Canon3DPhysics.VelocityZ to leave it as it is.
Or alternatively three different actions to set the only the X, only the Y or only the Z velocity separately would also work perfectly.
Thanks a bunch!
I'll add it to the list.
Awesome, thanks!
cool
Wow... will definitely buy and play with it this week. I feel like I have to remake my game now since all my characters are blob monsters and this will work so well........ so much work lol.
I guess this is a good alternative to heightmaps for slopes?
cool ! thinking of replacing all my enemies with this now. will this use deltatime by default in the future?right now even adding *dt to impulse give different speed at 60hz and 144hz
Yes, definitely will have that option in the future.
A suggestion: Can you add Apply Force features too and a tick option to prevent or not prevent rotation of 3d Shape?
I will add to the list, also support to control rotation
In terms of prevent rotation of 3D Shape, can you provide more information about what you mean?
I mean locking angle features(toggle) of 3d shape with 3d physics behavior enabled. I was trying to make custom physics control to the 3d shape and I added if key down -> apply impulse. But it seems that when this 3d shape collide with immovable 3d physics surface its angle also changes.
I see. I'll add it to the list.
Absolutely brilliant stuff, I especially love the raycast feature.
Thank you, if you doing something fun with let me know!
That paid version and all those features is an auto buy. 50-100 dollars is a fair price if 3d Object can rotate on all axis.
3D Object will be able to rotate on all axis, figuring out collision options for 3DObject: manual sized sphere, box, automatically sized sphere box (based on initial bounding box, I don't think dynamically updated)
More advanced (and heavier perf) cylinder:
const radiusTop = 0.5
const radiusBottom = 0.5
const height = 2
const numSegments = 12 (more, more perf)
const cylinderShape = new CANNON.Cylinder(radiusTop, radiusBottom, height, numSegments)
Would buy this so fast just for the raycast alone.
Incredibly exciting. Love your 3DObject already, so this is going to be a gamechanger.
🔥🔥🔥
its gonna be more great if can work with your 3D Object plugin, amazing work!
Your are genious man! I am very thankful that you have your attention on 3d physics too. I am really excited to see more updates on future. You are doing great man.