I was wondering, is there a way to keep the force applied to an object along an axis to stay along that axis? (ie. When the object rotates, the force is applied in the new direction) I have a character, and would like to use the force movement, but when you turn, it slides too much. And if this is not possible/practical, is there a work around?
I think you’re referring to “local” force. Use the “L” button next to the force on the motion actuator.
For sliding, you can adjust the friction on the material. One the materials tab, look for “DYN” near the color options. Click on this and then adjust the “Friction” slider.
I actually didn’t mean the Local force exactly. That just means force is added along the Axes of the object, instead of the Global Axes. I want the Force to not only be added only along a single Local axis, but to remain along that axis, no matter what direction it’s turned.
I’m still a beginner but I was able steer a dynamic object accurately and accelerate/brake it with a little bit of python. It took me days to figure it out and would probably take me the rest of today to post a example of the code. You might know that you can get and set velocity as triplets ie x,y and z components.
I chose the local y direction of my object as being straight ahead. I didn’t use actuators but applied force to the y direction only. When I rotated the object to steer it, it went all over the place. So whenever I steer it (using a script) I give it a velocity of zero in its local x direction.
If you continue to study python and experiment with the console you will figure these things out, plus a lot more.
Is there a way to set the total force of an object to a certain amount using Python? I figured out how to use it to access actuators and sensors, etc, but not set the forces of an object. Can anyone give a sample script (just a few lines) that shows the syntax, etc, of how it would work?
This is the script I tried, which didn’t work very well. I was using it in addition to Motion Actuators that added a Y force to the object.
import GameLogic cont = GameLogic.getCurrentController() obj = cont.getOwner() cont.getSensor("Always") = always if always.isPositive(): currentForce = obj.getForce() currentForce = Y currentForce = Z obj.setForce(0,Y,Z,1)
you can try something like this :
import GameLogic as g cont = g.getCurrentController() obj = cont.owner <b>always = cont.sensors["Always"]</b> if always.positive: # Note : if always is an Always Sensor, it's supposed to be always positive, I think. Y = 10 Z = 5 currentForce = obj<b>.getReactionForce()</b> # getforce() belongs to Class KX_ObjectActuator # getReactionForce() belongs to Class KX_GameObject # not sure getReactionForce() is the good one in that case, but couldn't find anything else here : http://www.tutorialsforblender3d.com/GameModule/ClassKX_GameObject.html currentForce = Y currentForce = Z obj<b>.applyForce</b>(currentForce,1)
Don’t have time to test it and there might be some errors still, but it should (I hope) get you closer to your expected result.
Basically, I need a way to control a character that moves dynamically, without sliding around like its on ice. Is there a way to do this that does not involve Python, or what? It seems like It should be possible to do.
See this thread (3rd screenshot).
Like I said I’m a beginner and you probably know more scripting and bricks than I do. You’ve posted some code since my last post. Maybe you’ve just forgotten that an object will continue to move when you cease to apply a force, as it would in space. Specifying in a brick that velocity or force only be delivered along one axis won’t stop the thing spinning and sliding if it’s rotated by you or collides with something. As has been said elsewhere fooling around with friction or force fields isn’t the way to solve it. If it’s a simple car on a track you
- apply force only to the longways axis (while experimenting at least)
- using just an always sensor (while experimenting) attach a script that always gives the car a zero velocity along it’s local sideways axis ie regardless of the cars orientation.
velocity = 0.0
It might be that you have to have a similar scipt attached to whatever gamepad or keyboard sensor your using to move the object. I experimented like that and in doing was able to learn more ordinary stuff as well. And then I found that I could get it all dowm to two sensors attached to one script. And then you can probably figure out how to give it a little bit of slide and ability to correct depending on it’s velocity, that kinda stuff.
It’s really easy, for me at least, to get confused, forget that blender is already taking care of a lot of the physics. And then forgetting that there’s still a lot that blender can’t possibly know unless I tell it.
If you know all this already, forgive me
See ya guys