cassius Posted December 7, 2013 Share Posted December 7, 2013 In my game two characters are in a sword fight. I want my main character to slowly push back the enemy character. What command do I need to do this? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
gamecreator Posted December 7, 2013 Share Posted December 7, 2013 If they're on level ground you can just have the enemy have less friction than the main character. Otherwise you can just push the enemy with an appropriate force. Quote Link to comment Share on other sites More sharing options...
cassius Posted December 7, 2013 Author Share Posted December 7, 2013 Sjould the force be added to the main character or the enemy character. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
ZioRed Posted December 7, 2013 Share Posted December 7, 2013 In your first post you said that you want your "main character to slowly push back the enemy character", so you need to apply the force (or Move if you're not using forces) to your enemy character. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
cassius Posted December 7, 2013 Author Share Posted December 7, 2013 I tried using addforce to enemy character with both positive and necative values but it had n effect. Canyou give me some idea of values required. But it maybe that se of y other code is nullifying the addforce code. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Rick Posted December 8, 2013 Share Posted December 8, 2013 Character controllers can't have forces applied to them. Something I did a long time ago was to also have a cone physics shape at the bottom of the feet of the character and when I wanted to push them back, I would disable the controller, and then push the cone back some via physics and have the character model follow it. When it stopped I would enable the controller again. Quote Link to comment Share on other sites More sharing options...
cassius Posted December 8, 2013 Author Share Posted December 8, 2013 Thanks Ric I will try that. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Naughty Alien Posted December 9, 2013 Share Posted December 9, 2013 ..i would do that trough game logic, where specific kind of attack will produce output result(s) such as push back..same should apply on to main character where such motion caused by AI action, affect player as well.. Quote Link to comment Share on other sites More sharing options...
Rick Posted December 9, 2013 Share Posted December 9, 2013 I think what NA is saying is another way to do it besides using physics, would be to do something where you specifically are setting the position of the character to simulate the push back effect. By using something like SetPosition() over every frame while said character is being pushed back, you can simulate, in a more deterministic way (it'll be the same every time). With the way I mentioned your character could fall over. When I did this some time ago I placed a very wide cone at the feet of the character to make sure it didn't fall over, but it still could have if something went wonky with the physics cone. 35 seconds into this video you can see it in action with the physics method I picked: Quote Link to comment Share on other sites More sharing options...
Josh Posted December 9, 2013 Share Posted December 9, 2013 Just use SetInput to make him keep walking in the direction of the player. Make the enemy's mass heavier than the player's if he isn't moving you enough. 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...
Joshua Posted December 18, 2013 Share Posted December 18, 2013 It is my assumption that a CharacterController is considered an 'infinite-mass' object which would prevent any external force from being applied to it or, the SetInput(...) method will negate any forces applied to the object because the SetInput(...) uses the objects position, rotation etc. What you might be able to do is use the SetInput(...) method and incorporate applied-forces into the method. Doing something like this should allow you to still apply forces without changing the character controller, or modifying the mass of the object. Quote Link to comment Share on other sites More sharing options...
cassius Posted December 18, 2013 Author Share Posted December 18, 2013 The enemy mass is much greater than the player mass and when they collide there is a slight pushing, but its brief and only happens once. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ 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.