#Adding scripts to objects

1 messages · Page 1 of 1 (latest)

frigid crown
#

Hello!
How are you?

I just added a cube to my scene and I am trying to make it spin but it is not. I made the same thing before and it worked normally.

here are my screenshots did I do something wrong?

earnest fulcrumBOT
earnest fulcrumBOT
# frigid crown Hello! How are you? I just added a cube to my scene and I am trying to make i...

Hello Aya Ali,

I'm here to assist you with technical questions. To help you with the spinning cube issue, I would need to see the relevant code you've used to create and attempt to spin the cube.

Please share the code snippet where you're setting up the cube and trying to apply the rotation logic. Just the screenshots won't be sufficient for me to diagnose the issue—you can copy and paste the code here or describe in detail what methods or properties you are using to spin the cube.

Remember that when working with rotation in Needle Engine, you typically would modify the rotation properties of the object3D component within the update lifecycle method of a component attached to that cube. If you can provide the code, I can give you more specific advice.

1 messages left GPT 4
thread_0uXHAosgEr381dyrP8m7kRaB
Thanks for your feedback!

sacred oar
#

Have you added the component to the cube and do you get your log from start() in the browser console?

frigid crown
#

No, I have Nothing in the console

sacred oar
#

Can you show a screenshot of the selected cube in your Unity scene where the inspector is also visible?

#

And also please in the browser

  • open the dev console
  • reload the page
  • send a screenshot of the console
frigid crown
sacred oar
# frigid crown

Is the script actually on the cube? Not visible on the screenshot

sacred oar
frigid crown
#

How to do that I mean I added it here

sacred oar
#

Scripts are just pieces of code. They need to be added to objects to do something with those objects.

#
  1. select the cube in the scene
  2. in the inspector, scroll down and click Add Component
  3. find your Rotate component and add that
#

If you have multiple objects that you want to rotate them each of them would have the „ Rotate“ script attached with its own settings (for example different rotate speeds)

frigid crown
#

wooho it is working

#

thank you

sacred oar
#

Ok 👌

#

Adding scripts to objects

frigid crown
#

I want to make the camera rotate but I can't attach it in code I tried to do some thing like this this.gameObject.getComponent(Camera)

#

But I couldn't control it

#

Is that even possible?

sacred oar
#

The camera is another object in your scene. If you want to affect it add your component to the camera gameObject. You’ll see that it already has the „OrbitControls“ component which does the default camera controls you see in the browser

#

You can add your own component to it and you can also remove the OrbitControls if you want to completely control it by your component.

#

There are also ways to reference components from other objects but I recommend you start with the basics 🙂

frigid crown
#

yeah, What I want just to make the camera move by using the keyboard Input

#

So, I will take your advice

sacred oar
frigid crown
#

Yeah, exactly I want the camera move like the player