It looks like you're new here. If you want to get involved, click one of these buttons!
So far I've tried a lot of things, these are 3 of them. Getting a bit frustrated at it.
transform.Rotate(Vector3.up * 50 * Time.deltaTime);
transform.Rotate(10, 0, 0);
transform.Rotate(new Vector3(10, 0, 0));
public float speed = 5f;
void update()
{
transform.Rotate(speed, 0, 0);
}
this worked.
Answers
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
public float rotationSpeed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(0f, rotationSpeed, 0f * Time.deltaTime));
}
}
to change what axis it rotates on change where the rotationSpeed is in the vector3
using UnityEngine;
public class Sword : MonoBehaviour
{
public float rotationSpeed;
void update()
{
transform.Rotate(new Vector3(0f, rotationSpeed, 0f * Time.deltaTime));
}
}
i tried using that and inside the inspector i made the rotation speed = 100
but it still didn't work :(
Both are wrong
Use this insted
Void Update(){
Transform.rotation = new vector3(transform.localRotation.x,transform.localRotation.y * speed * Time.deltatime, transform.localRotation.z);
}
That also didn't work, sadly.
im so confused as to why this is not working.
i've been using a cube i just created to test all of this, and another cube that's exactly the same but with a rigid body.
the 2nd box moves if i add gravity and hit it on the other cube so they aren't locked.
@AtticusDraxton Its quite simple you can do rotation in two ways using transform.rotate and transform.rotation.Use this
public float rotationspeed =60f;
public void Update ( )
{
transform.rotate (0f,rotationspeed * Time.deltaTime,0f);
}
Do you want rotation on the y axis?
And make sure the code is sitting on the same object which you want to rotate
Or else
public float Rotation;
void Update
{
transform.Rotation (0f,Rotation * Time.deltaTime, 0f);
}
transform.Rotate(Vector3.up * speed);
The GameObject Have RigidBody?? @AtticusDraxton
it doesn't need one