Jump to content

Picking Up Objects


wadaltmon
 Share

Recommended Posts

Just now, wadaltmon said:

I don't think that's it. If I set the character model to be taller, remove the outer cylinder, and make it so the held object can collide with Characters, it does the same thing with the character model itself.

And yes @TheConceptBoy: If we had that in C++ in an extensible form, this would be a non-issue.

I'm guessing my ball join solution was no bueno right?

 

Link to comment
Share on other sites

4 minutes ago, TheConceptBoy said:

I'm guessing my ball join solution was no bueno right?

 

It worked, but it didn't really fix the magic carpet problem. Certainly made it more forgiving like you said, but still possible. Also the slow and random way your held object moved toward the mouse was not quite what I was looking for. Definitely a good solution, but as far as what I want to accomplish in the final game, not quite the type.

That said, the quality of the tutorial was still top notch. 

  • Like 1
Link to comment
Share on other sites

25 minutes ago, Lethal Raptor Games said:

As in when using SetTargetPosition()?  I found using a very low mass made it accelerate and de-accelerate a lot faster.

How low are you talking? My masses are at 0.5. Perhaps setting the friction of the joint could work?

 

23 hours ago, TheConceptBoy said:

There's a video for leadwerks on moving objects using the Editor. We need THAT same thing but in C++

 

Righto! I ported this code to C++, exactly what I needed.

Link to comment
Share on other sites

4 minutes ago, wadaltmon said:

How low are you talking? My masses are at 0.5. Perhaps setting the friction of the joint could work?

Yeah I set mine to 0.1 but it wasn't perfect.  Lowering the friction of the kinematic joint changes how it effects the rotation and position of it's child.

Link to comment
Share on other sites

On 6/9/2019 at 5:23 PM, havenphillip said:

Maybe you could create a box around the player and use this Enter/Exit code from Aggror? But set it for Collision.Prop or whatever in an "if" statement?

 

Script.enabled = true
Script.entered = false
Script.exited = false
Script.collided = false

function Script:UpdatePhysics()
    if self.enabled then
        if self.entered then
            if self.collided == false then
                System:Print("Exited the trigger")
                self.exited = true
                self.entered = false
            end
        end
        self.collided = false
    end
end

function Script:Collision(entity, position, normal, speed)
    if self.enabled then
        self.collided = true
        if self.entered == false then
            System:Print("Entered the trigger")
            self.entered = true
            self.exited = false
        end
    end
end

So I'm a little fuzzy on how Lua functions, but when I was porting the carry objects Lua scripts, I saw a function like this Collision function. So if you write a function Script:Collision(entity, position, normal, speed), it's called whenever a collision happens with a given entity? How would I go about creating/using such a function in C++?

Link to comment
Share on other sites

What you'll need is an Actor in C++.  The script is basically an Actor (but in LUA) that attaches to an Entity.  An Actor is a class in C++ that attaches to an Entity.

 

Look in the Actor.h and Actor.cpp files for Leadwerks.  You derive from the Actor class like this.  I named mine cBaseActor, but you can name it anything you like.

class cBaseActor : public Actor
	{
	private:
	public:
		cBaseActor();
		~cBaseActor();

		//reDeclare the functions found in Actor.h, create a BaseActor.cpp and define your functions there like in the script
		void Attach();
		virtual void UpdateWorld();
		virtual void UpdatePhysics();
		virtual void Collision(Entity* ent, const Vec3& position, const Vec3& normal, float speed);
		virtual void UpdateMatrix();

		virtual void PostRender(Context* context);
}
cBasActor* _actor = new cBaseActor();
myEntity->SetActor(_actor);

 

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...