Jump to content

Picking Up Objects


wadaltmon
 Share

Recommended Posts

That does seem to have solved the problem, but it does present a new one. Say I was to pick up a given object that is very large, but it is light enough to carry or push. I can't push objects as it is with these collision types, unless I pick up a separate object and use it to push the other object along. But if I pick up a large object, it essentially places me inside of it, then when I place it down, I'm shot out of the object in some direction. Would it be possible to, instead of disabling collisions, just check whether the heldObject is colliding with the character at that given moment and then, if it is, just set its MotorSpeed to 0 (or just not set a new TargetPosition)?

Link to comment
Share on other sites

28 minutes ago, wadaltmon said:

I'm surprised there isn't a simple bool IsColliding (Entity* e1, Entity* e2) or something of that sort in Leadwerks. That seems like something that would be pretty fundamental for a 3D engine.

-- Lua Script
function Script:Collision(entity, position, normal, speed)
	


end

 

 

 

Link to comment
Share on other sites

1 hour ago, wadaltmon said:

I'm surprised there isn't a simple bool IsColliding (Entity* e1, Entity* e2) or something of that sort in Leadwerks. That seems like something that would be pretty fundamental for a 3D engine.

You could implement that in the Actor system, but I think why it's not there is because, unless it's a trigger, the collision is over and done with once the objects bounces.  It would only return true for an instant and it could be missed.

Link to comment
Share on other sites

I thought maybe a good idea would be to create a new Model* that is 1.25 times the size of the player and is parented to the player, and had a different collision type than the player (such that it was like there was a cylindrical shield around the player that the picked up object would bang against if it got too close, but didn't cause the player to drop the object. But I'm not sure if this is a good approach to the problem. My implementation doesn't work.

 

//player model created

Model* playerHb = Model::Create();
playerHb->SetPosition(0, 4, 0);
playerHb->SetScale(1.25, 30, 1.25);
playerHb->SetCollisionType(COLLISION_HBCHAR);

//other collision code happens

Collision::SetResponse(HELDITEM, COLLISION_HBCHAR, Collision::Collide);
Collision::SetResponse(COLLISION_HBCHAR, COLLISION_PROP, Collision::None);
Collision::SetResponse(COLLISION_HBCHAR, COLLISION_SCENE, Collision::None);
Collision::SetResponse(COLLISION_HBCHAR, COLLISION_CHARACTER, Collision::None);

Shouldn't the box bang against this invisible barrier around the player? Why is it not?

  • Confused 1
Link to comment
Share on other sites

3 minutes ago, Iris3D Games said:

Where documentation SetResponse??

It doesn't exist for some reason. But the function works as it should for disabling collisions between the held object and the player, then re-enabling them once it's dropped.

Link to comment
Share on other sites

Can anyone think of a way to implement it such that I could create essentially a very tall cylinder over the player that would interact with nothing but the heldObject, such that you can't bring the heldObject directly beneath you (or directly atop you for that matter)?

Link to comment
Share on other sites

11 minutes ago, havenphillip said:

You want to stop the player from rotating too far?

No, I've already got a pitch limit code in effect. But, without limiting the pitch max/min to be ridiculously limiting, the heldObject will still slip the player around as it moves toward the pivot used for object carrying. I'd like to essentially make a solid buffer zone around the player for the object to collide with if it gets too close, rather than making it collide with the player and make the player flya round.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

I got some of it fixed, but it seems that part of the problem is the fact that once you're in a certain distance of a low object, you instantaneously step up onto it. How do I lower the distance at which this happens? Should I just scaled down the player model (Model*)? If that would work, how would I do that? (playerController->SetScale() sets the scale of all objects!!)

Link to comment
Share on other sites

17 hours ago, Iris3D Games said:

Where documentation SetResponse??

Indeed why Isn't it documented? There's a pool of super useful functions floating around in the aether of the leadwerks header files that are essentially lost to new users who rely on the docs. Isn't that the whole point of the documentation? 

  • Like 1
Link to comment
Share on other sites

It's almost functional... but here's something interesting. I have a cylinder that provides a buffer around the player for the held object to collide with so it doesn't get too close to the player (or let the player clip into the held object). It works, except when I'm moving... if I move my player, the object suddenly is able to clip through the held object. I'm using SetInput to move my player... is this like the Move() function where it messes with the physics simulation? If so, is there an alternate way to provide movement to my player to make it so this doesn't happen?

Link to comment
Share on other sites

Okay. Take a look at this video. I show all the code here and a demo. You can see how there are 2 cylinders around the player, one is the player object itself and the larger one is the player buffer. You can see when I pick up the smaller box and move it around, it collides with the outer buffer cylinder. But when I move, it can clip through that outer buffer cylinder and slip behind the player. This should not happen; if the cylinder is moving, it should push the box along if it gets too close, right? Also, you can see when I pick up the larger box, it collides with the outer cylinder (and spazzes out a little, but I will fix that later). But when I move, I can clip into the box, causing it and me to shoot away from each other if I put it down while carrying it and am inside it. Again, this should not happen.

I know that Move() and SetPosition() can mess with the physics simulation. Is SetInput() this way as well? If so, how can I move my player where I want to go without using such a command?

Link to comment
Share on other sites

Not sure exactly but you could try calling these three lines after moving your heldObject and just before Time::Update();

.......

player->SetInput(mouseX, walk, strafe, jump);
carryPivot->SetInput(mouseX, walk * 2, jump);
cam->SetRotation(mouseY, 0, 0);

Time::Update();

SetInput() uses physics for controlling the character controller and shouldn't break the simulation.  I take it as your moving your mouse is still being held down?

Link to comment
Share on other sites

16 minutes ago, Lethal Raptor Games said:

Not sure exactly but you could try calling these three lines after moving your heldObject and just before Time::Update();


.......

player->SetInput(mouseX, walk, strafe, jump);
carryPivot->SetInput(mouseX, walk * 2, jump);
cam->SetRotation(mouseY, 0, 0);

Time::Update();

SetInput() uses physics for controlling the character controller and shouldn't break the simulation.  I take it as your moving your mouse is still being held down?

Hm. If it uses physics then why can my object clip through the cylinder? Shouldn't it be prevented from doing so at all? That change did not solve it unfortunately.

Also occasionally when I try to pick the object up a 2nd time I fall through the floor.

Link to comment
Share on other sites

9 minutes ago, Lethal Raptor Games said:

It could be that the character controller dosnt like being inside another physics shape.  You may have to find a different way to stop your held item from hitting your player.  Maybe a relative height limit?

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.

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