• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jknight-nc · Sep 05, 2016 at 07:54 PM · movementphysicsrigidbodyplayerplayer movement

Player is Speeding up in collisions

Hey there, I have a simple top down shooter Im working on.

Players can destroy the walls and then the debris will litter the level.

When the players run through the debris, they are speeding up. I don't know why this is happening.

I am using forces to move the players.

When I use ForceMode.VelocityChange, the players speed up when they are colliding with the level's debris:

     Vector2 force = direction * movementForce * Time.deltaTime;
     m_rigidBody.AddForce(force.x, 0.0f, force.y, ForceMode.VelocityChange);

When I Use ForceMode.Acceleration, the players slow down when they are colliding with the level's debris. Problem here is that they are slowing down way too much. To solve this, I changed the players rigid body mass to 2000 and the debris to 0,1. Player drag is 4, debris drag is 0.01.

I can't seem to find some values where the player just barely slows down when running through debris.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Spartiate0033 · Sep 06, 2016 at 12:55 AM 0
Share

I think your problem is two fold here. You don't have enough code provided to give a full answer so I will request you post how you activate when the player hits debris, you might be accidentally applying it multiple times.

As for slowing down the Player, you're going to want a speed modifier that can adjust the final result of force before it is assigned. I'm working on a similar game but it doesn't use force, just a simple translation. So what you'll want is to do is modify the speed based on the type of object it is colliding with.

 float step = (m_$$anonymous$$axSpeed * Time.deltaTime) * m_Speed$$anonymous$$odifier;

This is code from my game. So as you can see, the m_Speed$$anonymous$$odifier will effectively slow down the object when it walks on the debris. So you might have the m_Speed$$anonymous$$odifier = 0.25 or something when walking in debris, making the character walk at 1/4th the speed.

avatar image jknight-nc · Sep 21, 2016 at 05:38 PM 0
Share

I am using rigid body forces and dont want to use a custom "speed modifier".

I think the Player is "speeding up" because his collision with the cube causes him to leave the ground, and then in the air he has no ground friction and moves quicker. I thiiink thats what's happening.

Ultimately I made it so the debris applies no force to the Player's rigid body, and the player just pushes them around with impunity. It's funner this way.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rigid body child Player movement 0 Answers

Issues Making Character Move With Rigidbody 1 Answer

Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer

A simple solution for constant rigidbody movement without changing and clamping velocity directly 2 Answers

How does Rigidbody.MovePosition works ? What's behind the API? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges