Jump to content

wadaltmon

Members
  • Posts

    109
  • Joined

  • Last visited

Everything posted by wadaltmon

  1. 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.
  2. 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? Desktop 2019.06.11 - 23.08.41.01.mp4
  3. 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?
  4. 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!!)
  5. 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.
  6. 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)?
  7. 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.
  8. 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?
  9. 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.
  10. 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)?
  11. How would I go about running the SetCollisionType command respective to all the physics-enabled objects I have created if they're just objects I placed in within the level editor?
  12. I guess I'm not understanding more how essentially writing Collision::SetResponse(11, 12, 0) is going to relate that desired response to the actual instance of a given heldObject (which is just an Entity pointer). It's also worth noting that there's no documentation page for this command.
  13. Hm, I'm not really understanding the integer constants that are in there. What are the values held by PROP, CHARACTER, HELDITEM?
  14. Would anyone have any input on how to make it so prop surfing doesn't happen? I had tried to do a raycast downward (with a pickradius) to try and check if the object was directly beneath the player Model, but it wasn't remotely consistent. Is there a way to detect in real time if I am standing on top of a given Entity that has a pointer? BTW, attached is prop surfing vid 2019-06-08 17-01-58.flv
  15. That did it! And it even inherently allows me to throw stuff around (though I will have to mess with the friction, stuff is sliding around like crazy haha)! Will also mess with the motor speed to give it different speed depending on how quickly I move it around. Thanks everyone for the help! Here's the final code within the while(true): if (gameWindow->MouseHit(1)) { if (heldObject == nullptr) { Vec3 p = Vec3(gameWindow->GetWidth() / 2, gameWindow->GetHeight() / 2, 0); if (cam->Pick(p.x, p.y, pickinfo, 0, true)) { if ((pickinfo.entity->mass <= 0.6) && (pickinfo.entity->mass > 0.0) && (heldObject == NULL) && (pickinfo.entity->GetDistance(playerDummy->GetPosition(true)) < 2)) { heldObject = pickinfo.entity; heldObject->SetGravityMode(false); heldObjectJoint = Joint::Kinematic(0.0, 0.0, 0.0, heldObject); } else { //do something } } } else { heldObjectJoint->Release(); heldObject->SetGravityMode(true); heldObject = nullptr; heldObjectJoint = nullptr; } } if (heldObject != nullptr) { heldObjectJoint->SetTargetPosition(carryPivot->GetPosition(true)); if (heldObject->GetDistance(playerDummy) > 3) { heldObjectJoint->Release(); heldObject->SetGravityMode(true); heldObject = nullptr; heldObjectJoint = nullptr; } }
  16. That does work a lot closer to what I'd like, @Lethal Raptor Games. But, when I put an object down (click the button again), it leaves it in the air, and kind of messes up any future interactions with that object (as you predicted). On the plus side, this inadvertently created prop surfing.
  17. Not sure how you mean here. Is there a kinematic joint automatically associated with each physics-enabled entity? If not, how do I associate one with the object I pick up such that I can use that feature?
  18. I figured out the basic problem; it was the way I was disabling the carrying of the object on a second mouse click. It works kind of like I want it now; I can pick up an object, move it around, and then drop it. Here is the code there: if (gameWindow->MouseHit(1)) { if (heldObject == NULL) { Vec3 p = Vec3(gameWindow->GetWidth() / 2, gameWindow->GetHeight() / 2, 0); if (cam->Pick(p.x, p.y, pickinfo, 0, true)) { if ((pickinfo.entity->mass <= 0.6) && (pickinfo.entity->mass > 0.0) && (heldObject == NULL) && (pickinfo.entity->GetDistance(playerDummy->GetPosition(true)) < 2)) { System::Print(true); heldObject = pickinfo.entity; heldObject->SetGravityMode(false); } else { System::Print(false); } } } else { heldObject->SetGravityMode(true); heldObject = NULL; } } if (heldObject != NULL) { heldObject->SetPosition(carryPivot->GetPosition(true)); } So this works, but as of now, the carried object doesn't interact with the environment as I'm carrying it. Also, I'd like to be able to swing objects to the side and let go, and throw them. Plus, I want the speed of the object to be based on the speed of the mouselook. This should be able to be accomplished by basically changing the SetPosition function to a function that would say "MoveToPoint" where I could tell the entity to move toward a given point in space at a speed directly proportional to the difference in its position and the carryPivot's. But, it doesn't seem like that exists in Leadwerks. Is there such a function? How would i go about accomplishing that?
  19. Why would I switch to World::Pick? That operates completely differently; I'd have to constantly calculate the direction the camera was facing globally. If I could calculate that, I wouldn't need the pivot object in the first place; I could calculate the look vector and set the position of the carried object x units from the camera position in that direction. Also, won't this always return true even if I'm looking at an object I can't grab?
  20. Exactly. But the object still isn't lifting, it still just sits there. I'm not sure how I can check if the entity is actually being selected or at what stage the problem arises, as I can't really draw text to the screen. Double post?
  21. It is set to 0. When I was doing testing with the pick function, this basically made it to the position in the PickInfo filled by the pick operation was directly in contact with the entity, rather than being, say, 0.5 units off the surface of it. No matter the value I put in there, the code still doesn't work. EDIT: I should elaborate on this. Basically by using a pick radius above 0, I believe you allow for a pick operation to collide with a sphere around a potential pick point. By setting it to 0, I should only be able to pick relative to the actual geometry of the model.
  22. Hello. I'm currently wanting to make a game that uses physics similar to Half Life 2, and am doing so with Leadwerks C++ (don't really want to use Lua). Thus, I want to be able to pick up objects. I read a topic from about 9 years ago that covered this topic, but it didn't do so very in-depth. What I gathered from it is that in order to be able to pick something up, I'd use the pick functionality and then within the PickInfo, there is an Entity pointer that points to the specific entity that I'd want to pick up. However, I can't seem to get my code working. I created a ground and small platform in the level editor, each with collision type rigid body - scene. I also created a small box, with mass 0.5 and collision type rigid body - prop. The idea was that I could walk up to this box and pick it up and move it around, then simply drop it, each with a click of the mouse. The way I approached this was by creating a pivot that was parented to the camera, to keep the camera's rotation. I used carryPivot->SetPosition(Vec3(0,0,2)) to move the pivot to in front of the camera. I used the cameraPick function in my main while(true) loop when the mouse is clicked to try and choose an object, carry it, and then set it to the position of the pivot. Here's the code for that part: if (gameWindow->MouseHit(1)) { Vec3 p = Vec3(gameWindow->GetWidth() / 2, gameWindow->GetHeight() / 2, 0); if (cam->Pick(p.x, p.y, pickinfo, 0, true)) { if ( (pickinfo.entity->mass <= 0.6) && (heldObject == NULL) && (pickinfo.entity->GetDistance(carryPivot->GetPosition(true)) < 0.75) ) { heldObject = pickinfo.entity; heldObjectMass = heldObject->mass; heldObject->mass = 0; } } if (heldObject != NULL) { heldObject->mass = heldObjectMass; heldObject = NULL; } } if (heldObject != NULL) { heldObject->SetPosition(carryPivot->GetPosition(true)); } Remember all that is in my while(true) loop in main.cpp. There's more inside the while(true) loop than that, but that's the relevant stuff. What am I doing wrong here? How should I go about picking up an object in game this way (only such that they are objects I desire the player to be able to pick up)?
×
×
  • Create New...