Note versions 2.x.x the rapier physics engine with limited features. 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:

Buy Me a Coffee at ko-fi.com

Currently supported only on the 3D Shape.

  • 3D Shape: Box, Wedge, Corner-in, Corner-out, Prism, Pyramid
  • Only z axis rotation (3D Shape supports other rotation with the rotate 3d behavior)
  • Apply impulse (and towards position)
  • Immovable / movable
  • World gravity setting
  • 3D raycast
  • 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

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.
  • Heightfield
  • Add expression for x,y,z velocity
  • More 3D Shape shapes corner-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 masks
  • Apply force
  • Apply torque


Usage Notes:
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.
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

Note versions 2.x.x use an experimental rapier physics engine with limited features. Use only examples with 'Rapier' in the filename.

Updated 23 days ago
StatusIn development
CategoryAssets
Rating
Rated 5.0 out of 5 stars
(4 total ratings)
Authorkindeyegames
Made withConstruct
Tagsconstruct-3

Purchase

Buy Now$10.00 USD or more

In order to download this asset pack you must purchase it at or above the minimum price of $10 USD. You will get access to the following files:

raycastExample.c3p 1,013 kB
OnCollision-1-0-1.c3p 109 kB
raycastExample-mouselook.c3p 567 kB
collisionFilter.txt 5 kB
mikal_cannon_3d_physics-1.11.0.c3addon 84 kB
PhysicsAndRotate.c3p 1 MB
Raycast triggers.c3p 1,013 kB
spring.c3p 109 kB
Heightfield.c3p 200 kB
ssao-1-6-0.c3addon 6 kB
3DObjectPhysics.c3p 7 MB
mikal_cannon_3d_physics-1.18.0.c3addon 87 kB
mikal_cannon_3d_physics-1.19.1.c3addon 87 kB
Rapier Raycast triggers.c3p 1,013 kB
RapierKinematicCharacter.c3p 301 kB
RapierSimple-1.c3p 210 kB
RapierSimpleRotateTranslate-1.c3p 211 kB
mikal_physics_render-1.1.1.c3addon 6 kB
mikal_cannon_3d_physics-2.7.0.c3addon 771 kB
RapierJointsMinimal.c3p 395 kB

Development log

View all posts

Comments

Log in with itch.io to leave a comment.

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...

(1 edit)

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.

(1 edit)

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?

(1 edit)

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.)

(1 edit)

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?

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

(3 edits)

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)

(1 edit)

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!

(+2)

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.