- Home /
Rotating gameobject not colliding
Hello, i have something like atrap in the game that rotates around and has spikes on it. The problem is that its not colliding with the player. I think i must use force but how cna i make it rotate?
There is not enough information here to help.
The problem is that its not colliding with the player : does the the trap simply go through the player, or stops when colliding with player?
What is your player, a character controller or a custom rigidbody controller?
think i must use force* : are the moving parts of your trap using rigidbody?
how cna i make it rotate : how can you make what rotate?
yes sorry,
no there is no rigidbody nowhere, the trap goes through the player that uses char controller.
Here si a image of the trap http://img16.imageshack.us/img16/1347/94ef.png
So i want it to rotate with a stable speed and colliding normally with the player how can i do that?
Add a box collider to the trap. To spin the object attach this to object you want to spin. No need for any rigidbody. As you are probably checking the collision on player, oridinary oncollisionenter function wont work, you have to use oncharactercontroller. http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html
When your player collides with the object, you can getcomponent of the colliding object script, in this case It's script called Rotate, and call the function Action() which will stop or continue spinning the trap.
using UnityEngine;
using System.Collections;
public class Rotate : $$anonymous$$onoBehaviour {
public bool spin;
void Start(){
spin =true;
}
// Update is called once per frame
void Update () {
if(spin)transform.Rotate(0,1f,0); //Set the number 1f to higher or lower depending on fast yo want it to go
}
void Action(){
if(spin) spin = false;
else spin = true;
{
}
Thanks but i dont want to use the collision event yet. I just want to make the trap stronger than the player so it can throw him off the road. How can i do that?
Your answer
Follow this Question
Related Questions
Add force at position Question 1 Answer
Rotation Force on a model 2 Answers
Rotating a boat on two axes with force. 2 Answers
Rotate Object to Euler Angle using Physics? 3 Answers
Ball Rotating Help 0 Answers