Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no CollisionMesh in examples #63

Open
CrossroadInTheVoid opened this issue Jun 17, 2023 · 6 comments
Open

There is no CollisionMesh in examples #63

CrossroadInTheVoid opened this issue Jun 17, 2023 · 6 comments

Comments

@CrossroadInTheVoid
Copy link

There is no CollisionMesh in examples and it works totally unclean.

It worked like this in the past:

collision = require("3DreamEngine/collision");
...
self.box_collider_mesh = dream:loadObject("models/collider_box", {splitMaterials = false, noCleanup = true});
...
local _collider = collision:newMesh(self.box_collider_mesh);
...
_collider:moveTo (vec3(_vector_a.x, 0, -1 * _vector_a.y)); --or any other action with created collider

But as I see it was changed. What should be included to fix

attempt to index global 'CollisionMesh' (a nil value)

error? What parametres should I use?
CollisionMesh:newCollisionMesh(mesh, shapeMode)
What the mesh is? Loaded mesh object? Or a string path to an obj file? Link at documentation looks dead.

P. S. I'm thisnickwasfree, I've lost access to that acc so I've created new one.

@Luke100000
Copy link
Collaborator

Welcome back!

The physics has been extracted into its own extension: https://3dreamengine.github.io/3DreamEngine/docu/extensions/physics

Specifically this is how to create a shape (the prepared collision mesh) and world:add (which then creates an collider)

--create a shape from this object and it's current transformation
local shape = physics:newObject(object)

--add this shape to the world
local collider = world:add(shape, "dynamic", x, y, z)

@CrossroadInTheVoid
Copy link
Author

Thanks. But:
Error: extensions/physics/world.lua:261: attempt to index field 'physics' (a nil value)
Where is the creation of love.physics table?

@Luke100000
Copy link
Collaborator

Either in the conf.lua https://love2d.org/wiki/Config_Files or you can require it manually love.physics = require("love.physics")

@CrossroadInTheVoid
Copy link
Author

Oh, it was switched off in config. Thank you. And sorry for disturbing, take my questions as «dumb user test» for your project.

@CrossroadInTheVoid
Copy link
Author

And some more questions.
Method moveTo removed. So, how to move collider to vec3 coordinates? I guess applyForce or applyLinearImpulse are not the best way.
I've used colliders to detect mouseclicks at mobs and raycasts between mobs. Looks like it's not good choice for such a thing now and I should use RaytraceMesh?

@Luke100000
Copy link
Collaborator

Yes, use raytracing for that. The physics extension is 2.5D and is based on Box2d. Setting position is an oversight from me, will add that, but it boils down to collider:getBody():setPosition(x, z) and collider.y = y where body is a love2d physics body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants