Hi! I´m trying to make a simple platforming game where the player moves around a sphere (like if he was orbiting it) and where he needs to push boxes in order to solve puzzles.
The whole thing was working quite well, until I noticed that the collision detection system was doing crazy thing when the gravity vector was too different from the y axis (I was using CharacterController). I read on the forums that the CharacterController only works when the gravity is applied in the y axis (or is predefined in the Physics tab). So… Yeah… I´m stuck now…
I think I should be using Rigidbodies, but I am not sure of how to implement them nor if I should be using them at all… I just need a simple can´t-go-through-walls kind of movement…
So I have been working with this and made a rigidbody controller that would let me orbit arround the sphere and detect collisions quite nicely. The only problems now are that the player bounces a lil bit when colliding and that he can´t jump while trying to go through an object (like if it was having some kind of friction that wouldn´t allow him to move upwards).
The controller uses rigidbody.velocity to move the player. The directions of movement are calculated and then passed as a velocity vector.
I have never used a rigid-body character controller but to have things interact slightly different with the physics you could try to create a separate physics material for the player.
The thing is I am not using materials and that I just need a way of avoiding object to get one through another. Like I said in the first post, character controller doesnt work because gravity isnt applied on the y axis… If anyone know a better way of doing this, plz tell me.
I can post a very short demo or video to demonstrate what I need/say, but I think that rigidbodies might be the way to go
This doesn´t seem to work… Again, I believe my problem can be fixed in a much simpler way…
The basic problem is avoiding objects penetrate each other while moving. Is there a simple way to do this? I already tried:
-Character Controller: Doesn´t work with gravity pointing away from y axis
-Raycasting: Choppy and fails most of the times…
-Rigidbody: Seems to work fine, but I still have problems with moevement, The player does shacking-like movements while walking and gets suspended in the air when pressed against a surface…
So… I kept on working and I found out on the internet that if you put your camera position update on a FixedUpdate it just works. So I did it, and it works .
Only problem now is that I think that this is like an illusion that the camera creates: the shaking is still there. I just put a block that you can push when the character and it seems to do the same shaking movement the Player was doing… Do you know how can I fix it?
@James: AddForce only works with the ForceMode modifier that changes the velocity, which is the exact same thing than changing the velocity… I´ll experiment a bit with material to see what I can get, but I don´t believe I´ll fix it that way…
That’s not what I asked, but your response is still incorrect. Setting velocity and using forces are quite different.
example…
I can make a tank hover in mid air if I constantly set the velocity to zero, as it cancels out all other potential forces. It will also ignore settings like drag, mass, etc
However, If I constantly AddForce to the same tank, its going to be pushed in that direction, but also take into account any other physics (ie gravity, collisions). So you an see they are very different (unless your velocity calculation takes into account all the other potential parameters).
Anyway, my question was actually about how you are moving your object… if you are using transform.Translate (which is the common thing to do when you first start learning), you are overriding the physics stuff, which will allow you to push through colliders. It can also result in jittery movement.
Also, camera movement should be done in LateUpdate