Jump to content

Kicking Boxes


Yue
 Share

Recommended Posts

I don't know how to tackle this problem, I need my player to kick boxes, but I need to structure it the right way.

In other programming methods I tackle the problem by going through a collection to identify if a lightning bolt is touching a certain box.

 

For Box:TBox = eachin TBox
	
	if ray = box.entity then
		' Kick Box.
	end if 

next


image.png.91e10e3ace926c8a16ff2afabeac9656.png

However here I find no way to do it, any suggestion?

 

 

Link to comment
Share on other sites

19 minutes ago, Lethal Raptor Games said:

You could;

Create pivot.

Parent pivot to the foot bone.

Create Box shape for the pivot.

Enable collisions between the box and pivot as Trigger.

In the scripts Collision() function -> Get the box entity and AddPointForce() at the collision position.

How do I get the pivot foot?

 

 

Link to comment
Share on other sites

It doesn't work, in the tests I take the pivot of the head, to the pivot of the head I apply a shape, then under the stature of the controller of the character controller but it doesn't collide that shape that is in the bone of the head.

 


Función Script: Inicio ()
		
		self.pivotCabeza = self.entity: FindChild ("Cabeza")
		forma local = Forma: Caja ()
	
		self.pivotCabeza: SetShape (forma)
		forma: liberación ()

		self.pivotCabeza: SetCollisionType (Collision.Prop) 
		self.pivotCabeza: SetPickMode (0, falso)

		self.component: CallOutputs ("OK")
		self.entity: PlayAnimation ("Idle", 0.02)
fin

 

image.png.be93121774aae1edd0f94d773017fe62.png

 

 

Link to comment
Share on other sites

You won't need the head bone for this.

FOOT = 10
CRATE = 11

self.footbone = self.entity:FindChild("nameoffootbone")
self.footpivot = Pivot:create(self.footbone)
self.footpivot:SetPosition(self.footbone:GetPosition(true),true)

local shape = Shape::Sphere()
self.footpivot:SetShape(shape)
self:footpivot:SetCollisionType(FOOT)

Collision:SetResponse(FOOT,CRATE,Collision:Trigger)

///////////////////////////////////////////////////////////

function Script:Collision(entity,position,normal,speed)
	entity:AddPointForce(position,Vec3(0,0,100))					//Add the force to the box
end

This is basically what I mean.

 

EDIT : I haven't used LUA in ages so syntax will probably be off.

  • Like 2
Link to comment
Share on other sites

You may have to put some timing checks in place, because for a period of time the foot pivot will be inside the box and will constantly add a force.

lastTime = 0
function Script:Collision(entity,position,normal,speed)
	if(Time:Millis() > lastTime + 1000) {							//Only add if the kicks are spaced by 1 second
		entity:AddPointForce(position,Vec3(0,0,100))					//Add the force to the box
		lastTime = Time:Millis()
	}
end

Something like that.

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

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


	if entity:GetKeyValue("name") == "Caja" then
		entity:AddPointForce(position,Vec3(0,5,12),true)	
		entity:SetOmega(Vec3(0,0,0))
	end 

end

Today, trying to implement this, I have the following problem.

Initially a collision is checked, so the box is propelled no matter what collides with the boxes, in this case the player's controller is colliding before the bone in the right foot.

This implies that the boxes are thrown with force when touching the player's controller, my question: How do I associate that this only happens when the right foot bone touches the box, in this way when making this collision throw the boxes away. This is because the kick should only be activated when the player or the mesh performs the animation of the kick, this implies that the foot touches the box. 

Translated with www.DeepL.com/Translator

 

 

Link to comment
Share on other sites

In the learning process I have taken up the problem from another perspective, the use of a ray, which comes from the bone of the head at the height of the eyes of the character, this is interesting because through this method you can establish a range of visualization of the character and in this simple example I have a ray that comes out of the eyes and destroys things, it is only a prototype. In this case you can evaluate what the ray touches and therefore establish what happens to that object. 

Translated with www.DeepL.com/Translator



:D

 

  • Like 1

 

 

Link to comment
Share on other sites


Here we have the same approach, only that the ray comes from the bone of the right foot, and the new thing is that with the key E, active that the box that touches disappears, in this point I think that the of the bones is unnecessary, would only be to establish that the ray comes out of the player to the height of his feet, and when this near of the box, the key E is pressed of a kick and the box is kicked.  
 

 

 

Link to comment
Share on other sites

52 minutes ago, Josh said:

You might want to change the order of your post-processing scripts. The SSAO looks kind of weird above.

 

I think this is trial and error and I changed the order of the scripts and I think it looks better.

Continuing with the box, trying to understand how to make the box be thrown in the direction the player is looking, because sometimes it goes the other way.
 

 

 

Link to comment
Share on other sites

pick.entity:AddPointForce(pick.entity:GetPosition(true),Vec3(0,200,300),true)

This is what I have to kick the box, but I don't know how to make it go in the right direction.  That is to say that the box is flying in the direction where the player is looking, but sometimes the exit path of the box is incorrect. 

Any suggestions?

 

 

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