Collision between two GameObjects causing an increase in velocity
Hi,
I have two GameObjects:
a Player GameObject that has a BoxCollider2D and RigidBody2D, and a script carries out movement by declaring a Vector2 from Input.GetAxisRaw("Horizontal"/"Vertical"), multiplying that by some 'movementSpeed' and assigning that to the RigidBody2D's velocity. (This is just a simple WASD movement script.)
a test NPC GameObject that has a BoxCollider2D and RigidBody2D, and a script that carries out movement through pathfinding and assigning the transform's position directly (using Vector3.MoveTowards).
When I move the player into the the NPC, from what I can tell, the NPC then gets the velocity from the player and moves virtually forever. If the NPC collides into the player, the reverse doesn't occur (but the NPC does jitter on collision - an undesired behavior).
My current goal is to have the GameObjects simply nudge each other out of the way (StarCraft2 allied unit collision).
Removing the RigidBody2D from the NPC causes the NPC to become an immovable object and pushes the Player around.
Details regarding both RigidBody2D components : - Dynamic - Simulated : ON - Use Auto Mass : OFF - Mass : 1 - Linear Drag : 0 - Angular Drag : 0 - Gravity Scale : 0 - Collision Detection : Discrete - Sleeping Mode : Start Awake - Interpolate : None - Constraints - Freeze Position X : OFF - Freeze Position Y : OFF - Freeze Rotation Z : ON
Thanks for any time and help.
Your answer
Follow this Question
Related Questions
According to Collision Change Rotation of Car 1 Answer
Bad collision detection in client's view when using Networking (Mirror) 0 Answers
Enemy script stops working after the first group of enemies 0 Answers
CollisionDetection of manual scaling Object (2D) 0 Answers
changing physics/collision interactions based on type 0 Answers