rappax.blogg.se

Bounce when touch collision unity
Bounce when touch collision unity








I tried to use the different physic material, but good results i can receive only at high frequency of FixedUpdate Cycle If change the Time.fixedDeltaTime to 0.005 (FixedUpdate cycle at 200 Hz) the result will more realistic If I fire directly to wall (the ray of shoot aligned with normal to plate of the wall) - all good (red ray - target cursor, greed ray - the arrow movement path)īut if i Shooting under the angle to the wall the arrow bouncing at the collision point on near ~ 0.2m, shooting distance near 2m (Time.fixedDeltaTime = 0.02, FixedUpdate cycle at 50 Hz) The arrow is the Gameobject with Rigidbody (mass:0.35, Drag:1 AngDrag:0.1 collision mode = continuous). Stopping completely is only acceptable when the player collides with a wall as they're facing it straight, but if there's an angle, I would like the player to "slide" along the wall.I made the archer which fire arrows to the wall. I think I should also mention that I don't want the character to just stop when it collides with the walls and therefore I don't think using triggers and such is a good idea. The walls (3D model) have a simple mesh collider on them, nothing more. Position is not frozen, but the rotation is for all X, Y and Z coordinates so it wouldn't fall over. Transform.Translate(rotation * direction) Ĭharacter that has the movement script has a capsule collider and a Rigidbody with mass: 1 drag and angular drag: 0 is using gravity, is not kinematic, interpolate is set to none with collision detection set to discrete. Quaternion rotation = Quaternion.Euler(new Vector3(0,, 0)) Vector3 direction = new Vector3(, 0, ).normalized * speed * ltaTime

bounce when touch collision unity

Here's the bit that is responsible for the movement of my character and I believe this has to be changed to something else: if (isWalking)

bounce when touch collision unity bounce when touch collision unity

It almost feels like the Rigidbody character is continuously trying to go through the walls even though it can't.įor the most part this wouldn't be too big of an issue, but there are some corners in the game that have other smaller objects that also have mesh colliders on them and should the player get in between these objects and the walls, they would simply be pushed (bounced) out of the game area and through the walls altogether. So far I've found nothing that will help me and I've tried messing around with physics materials, freezing/unfreezing constraints of my Rigidbody, setting angular drag to infinity, etc.Īs I've learned, the problem should be that my Rigidbody is penetrating the walls that have mesh colliders on them and it gets pushed back out which results in this weird "bouncy behavior". I'm building a VR maze game for Google Cardboard with the as the script which moves the player.










Bounce when touch collision unity