Jump to content

SpiderPig

Members
  • Posts

    2,411
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. You would have to remove the joint.  Try this when you click again;

    ..........
    else {
    		heldObjectJoint->Release();
    		heldObjectJoint = nullptr;
    
    		heldObject->SetGravityMode(true);
    		heldObject = nullptr;
    }

    I did a quick test and it doesn't delete the child object (heldObject in this case).  I'm not sure how it will work though.

    • Like 1
  2. Joint* heldObjectJoint = nullptr;
    
    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;
    				
    				heldObjectJoint = Joint::Kinematic(0.0f, 0.0f, 0.0f, heldObject);
    			}
    			else {
    				System::Print(false);
    			}
    		}
    	}
    	else {
    		heldObject->SetGravityMode(true);
    		heldObject = NULL;
    	}
    }
    
    if (heldObject != NULL) {
    	heldObjectJoint->SetTargetPosition(carryPivot->GetPosition(true));
    }

    You could try this, not sure how removing the joint would go but you could play around with it a bit.

  3. Want I want is exactly what you have done with your character controller, but align to different gravity directions.  What I'm doing to try and achieve it is this;

    • Create Capsule Shape
    • Apply constant force of gravity
    • On Actor::Collision();
      • Store collision point and normal
      • Store collision time
      • Turn off gravity
      • Set Velocity to 0
    • On UserInput to move;
      • Create Plane with the normal and position
      • Use angle of character to find a point exactly 1 unit away
      • Intersect the plane with a ray aligned with gravity at that move point
    • Move capsule with SetVelocity() or PhysicsSetPosition()
    • In Actor::UpdateWorld();
      • Use PhysicsSetRotation() to align the capsule with gravity
      • Speed = GetVelocity().Length()
      • If speed is not 0 and the collision time is greater than 100ms ago, enable gravity.

    Using a kinematic joint has the same problems as above but with the addition of slowly rotating to align with gravity and not being snappy when moving to the target unless mass is really really low.

    I've also tried, setting the collision response off for the capsule and finding all entities in the AABB around the capsule, and ray casting each shape to find the collision point.  This work smoothly and was great except FPS dropped from 100 to 70 (just with one Pick per frame as it was moving) so this was not ideal.  The fact that this worked told me that the problem lies with the capsule still colliding with the ground as I move it.

     

    I think what I want can only be done under the hood with newton commands.

     

     

     

  4. Ah I see what you mean now.  I got it to work but the kinematic joint still gives me trouble where the object will drag across the ground and jitter.  I think the problem is, it drags and gets a new rotation, and then next frame the target rotation is set, causing a jitter between the two.  Is Joint::Vector() able to be moved at all?  I know it can be moved around if something hits it, but I want to add forces to it...

  5. I've tried this but it doesn't work for me.  I'm calling SetTargetPositon() but else where I'm calling AddForce() to the child of that joint to simulate gravity.  This seems like it may be bad?

  6. Vector seems to constrain the child enity well but setTargetPosition dosnt seem to work and there is no other way to move the joint.  ?  unless I parent it to another entity maybe, but that might defeat the purpose...

  7. If an object has root motion, that means the bones / mesh must move away from the origin point so the character can't be parented to the controller... or you could parent the character to the controller, move the controller forward based on the root motion and move the character entity backwards at the same rate... ?  Code to manage this could be written once and then all movements would be controlled via animations.  I can see this being good for animals that run around all over the place, but for a character... not sure..

  8. I think whats happening is the animator will move the root bone in the direction of travel, and then you copy that movement to the character controller.  It would take some working out but I don't think it'll be too hard to implement.

    Quote

    Root motion is better because it's more realistic, immersive and looks more polished.

    That's what I was thinking too.

  9. Anyone heard / have thoughts on root motion vs treadmill motion for Leadwerks?

    As far as I can tell; Treadmill motion is where you move the characters controller via code at a constant speed, and root motion is where you let the root bone of your animation say how fast and far your controller moves.  Just wondering what your thoughts are on both approaches :)

×
×
  • Create New...