- Home /
Rigidbody bounce or character controller istrigger issues
I have an object that is an object that is suppose to be a fish and has a rigidbody and sphere collider and it, of course, bounces around if it hits any object with a collider since I have disabled gravity. After looking on Google I found out I could use the character controller to get around this but my istrigger based script functions don't work. Even though, I have a sphere collider with istrigger checked. Though the reason is currently slipping my mind, I was having trouble with a previous problem that could only be solved by using istrigger and I can't use the collision function. Also, I know I could use iskinematic or freeze rotation and position to stop it but now my object will go through walls and I also don't want that either. any ideas?
EDIT: OK maybe the above explanation is a little vague. So basically I have a fish swimming around underwater shooting bubbles and collect food to become stronger. there are also areas of rushing water that will push this fish around. I also have code set up so I can add a versus mode later. My problem is that when this fish hits a wall I simply want it to not go through or bounce off it or even continues to increase in speed in the direction opposite of the wall until it hits another wall. I simply want it to stop the fish from going through the wall. here the whole list of code I have for the movement. Note: I have a lot of commented out code I have leftover from trying to figure out other problems.
DELETED
EDIT2: I have fixed this by adding the code below to Late updater.
rigidbody.velocity = new Vector3(0f,0f,0f); rigidbody.angularVelocity = new Vector3(0f,0f,0f);
But now I got a new error message saying
Actor::setLinearVelocity: Actor must be (non-kinematic) dynamic! UnityEngine.Rigidbody:set_velocity(Vector3)
I personally don't care since I got what I wanted (unless this turns out to be an actually problem) but this error message is really annoying.
Describe bouncing around. Do you have any physics materials on them?
This doesn't really make a whole lot of sense. It's bouncing around. Ok, WHAT DO YOU WANT IT TO DO??? lol
one thing I may have forgot to mention is that this fish is controlled by the player and moves around using transform.position += speed*Time.deltaTime. I have no physics material on it and I basically want it to stop when it encounters a wall not slow pick up speed moving in the opposite direction of the wall until it hits another wall.
Nope still bouncing around but it appears to also jerk back and forward now. here is a sample of the code I'm using: Forward = Input.GetAxis("Forward1");
rigidbody.position += transform.forward* (trueSpeed*Forward)*Time.deltaTime;
Your answer
Follow this Question
Related Questions
Activate physics when animation ends 0 Answers
attached.Rigidbody isn't working with a ChactacterController? -1 Answers
Picking up items with Rigidbodies 2 Answers
How to make jump something without using a character contoller? 2 Answers
mesh colliders problem 1 Answer