#rotation issue

1 messages · Page 1 of 1 (latest)

primal sundial
#

Can you sent the screenshot here?

#

Btw it is against the rules to DM Unity staff 😄

urban sierra
#

Are you a unity staff?

#

XD

primal sundial
urban sierra
#

I don't give attention to that haha

primal sundial
#

No worries, let's try and fix the issue 🙂

urban sierra
#

You want me to send the pivot like that?

primal sundial
#

Is local world space selected?

#

So... When does the rotation not work? Only when spawned? And now it does work...?

urban sierra
#

Global is selected and rotation dont work when I have spinObjects script declared to both of my objects bomb and money

#

When I remove this script then everything works fine but with no spin

#

I will show you right now

primal sundial
#

Can you select local?

#

I think the 3D model's pivot point is wrong 😄

urban sierra
#

I will select right now

primal sundial
#

After you select that, where's the pivot?

urban sierra
#

I check the constraints and check those ones that were also in the balloon constraints, so i checked x and z positions and rotations except y pos and y rot

#

I select pivot right now

#

It was centered like you said

#

But

#

Let me test it

primal sundial
#

It won't change it

#

It just shows were the pivot of the GameObject is

#

Can you share the code?

urban sierra
#

No, it doesn't change anything

#

I think the problem wasn't about the pivot

#

I had it centered and balloon was flying fine, the others have problem

#

Now, I will send you the code I think the issue is in the code

#
{
    // Our variables 
    public float spinSpeed = 50;

    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(Vector3.up * spinSpeed * Time.deltaTime);
    }
    
}```
primal sundial
#

Seems good to me.

urban sierra
#
{
    private PlayerControllerX playerControllerScript;
    private float leftBound = -10;
    public float speed = 10;


    // Start is called before the first frame update
    void Start()
    {
        playerControllerScript = GameObject.Find("Player").GetComponent<PlayerControllerX>();
    }

    // Update is called once per frame
    void Update()
    {
        // We give speed only to our background
        if (playerControllerScript.gameOver == false)
        {
            transform.Translate(Vector3.left * speed * Time.deltaTime);
        }
        

        // If object goes off screen that is NOT the background, destroy it
        if (transform.position.x < leftBound && gameObject.CompareTag("Bomb"))
        {
            Destroy(gameObject);
        }

        if (transform.position.x < leftBound && gameObject.CompareTag("Money"))
        {
            Destroy(gameObject);
        }

    }``` This is the code for the movement to the left
primal sundial
#

That won't influence those objects I assume?

#

Also just in case make them kinematic

urban sierra
#

What do you mean by that cuz I am a beginner I dont know?

#

Like 2-3 months experience

primal sundial
#

Unfreeze the constrains as well

urban sierra
#

Wait constraints you mean

#

Ok

primal sundial
#

Can you select a bomb clone?

#

And sent me a screenshot / video of that?

urban sierra
#

Οκ

#

Like I see it is a little bit to the right

primal sundial
#

Aha. I see the issue now

urban sierra
#

Really?

primal sundial
#

MoveLeft script is attached to it and it does this: transform.Translate(Vector3.left * speed * Time.deltaTime);

urban sierra
#

So, I have to remove this script from these objects right?

primal sundial
#

Or remove that line of code 😛

urban sierra
#

I can't remove them. If I remove them they will not be moving to the left

primal sundial
#

Well. The way you move them to the left is not correct.

urban sierra
#

This script is attached also to the repeatBackground script

primal sundial
#

In combination with the rotation that will cause them to rotate around a pivot

urban sierra
#

The moveleft one is attached to the background

#

Maybe I have to make another script.

#

I will try to remove this line of code

#

And check it out

#

So, in your opinion where is the problem in which one of the scripts?

#

In move left one?

primal sundial
#

Haha it depends on what you want to achieve. If you just want to rotate the GameObject, then MoveLeftX script should not be attached to that bomb GameObject

urban sierra
#

When I zero the spinspeed of these objects then the functionality of the game works pretty fine

#

When I give a value to the spinspeed something goes wrong

primal sundial
#

It's because you are rotating the GameObject and using a translate to move the GameObject at the same time thus it moves around it

#

You might need to use translate but in world space

#

transform.Translate(Vector3.left * speed * Time.deltaTime, Space.World);

urban sierra
#

Oh, I delete it when I was reading it at the start of this project

#

I don't know why I delete it but I thought it was a mistake

#

It was a challenge this project

#

And I had to make some debugging

#

I solved the problem thank you. It was the space.world that I removed