Yue Posted March 31, 2019 Share Posted March 31, 2019 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 However here I find no way to do it, any suggestion? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 I take it your character is animated? If so the foot bone will be a child of your player entity. Entity::FindChild("nameofbone"); 2 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 This led me to think that I could turn the bone of the player's head with the angle of the camera, but you can not, the animation does not allow it. I'm going to try what you say to kick the box. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 Can the shape be scaled? Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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 Quote Link to comment Share on other sites More sharing options...
havenphillip Posted March 31, 2019 Share Posted March 31, 2019 If you're childing a pivot to a foot, you could maybe add a script to it that uses Cabeza = self.entity:GetParent() and set the collision type etc. from there. Then you could reference it from your script above. 2 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 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. 2 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 Thanks You!! Kick Box.mp4 I guess I have to work on an animation for the kick and look at different kinds of force. 2 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 Looks good! You've got something to play around with now at least. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 The thing is that the boxes fly away like crazy, I do not know what parameters to move so that the kick does not have so much force. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 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. 1 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 Test Box Kick.mp4 Always something new to learn. 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 Never ending 1 Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted March 31, 2019 Share Posted March 31, 2019 Could turn this into Robot Soccer. 2 Quote Link to comment Share on other sites More sharing options...
havenphillip Posted March 31, 2019 Share Posted March 31, 2019 This is looking pretty cool. I kind of want to join this project. 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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 Test Pick Ray.mp4 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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. Test Ray Pick Key E.mp4 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 You can call GetCollisionType () to see if it matches the boxes. ? 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted March 31, 2019 Share Posted March 31, 2019 You might want to change the order of your post-processing scripts. The SSAO looks kind of weird above. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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. Kick Box.mp4 Quote Link to comment Share on other sites More sharing options...
Yue Posted March 31, 2019 Author Share Posted March 31, 2019 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? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 31, 2019 Share Posted March 31, 2019 It looks much better now. I see you're adding 200 in the Y direction which seems too much. You can get the facing direction of the player and add a force in that direction. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.