Jump to content

Recommended Posts

Posted

Hi, I'm having some issues detecting the collisions between entities, I created my own object that inherits from Leadwerks::Model and overloads the method "OnCollision", but the method does not seem to be called. here is my code:

 

class Player : public Leadwerks::Model
{
private:
	bool grounded;
	Model* model;
public:

	Player() : Model::Model()
	{
		grounded = true;
		model = Model::Box(2, this);
		model->SetPosition(0, 1, 0);
	}

    void OnCollision(Entity* other, const Vec3& position, const Vec3& normal, float speed) override
    {
		if (reinterpret_cast<Terrain*>(other))
		{
			grounded = false;
		}
		std::cout << "EwE" << std::endl;
    }
	void setGrounded()
	{
		grounded = true;
	}
	bool isGrounded()
	{
		return grounded;
	}
};
          
	Player* playerDummy = new Player();
	playerDummy->SetPhysicsMode(Leadwerks::Entity::CharacterPhysics);
	playerDummy->SetPosition(0, 4, 0);
	playerDummy->SetMass(1);
	playerDummy->SetKeyValue("Name", "Player");


	Leadwerks::Map::Load("Maps/temp.map");

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...