spinning-cube | A trivial example of cross-compiling C | Binary Executable Format library
kandi X-RAY | spinning-cube Summary
kandi X-RAY | spinning-cube Summary
This repository demonstrates a native application using OpenGL that's been compiled to the Web without any modifications to its source code. With WebAssembly, the Web is just another compiler target. Example sourced from
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spinning-cube
spinning-cube Key Features
spinning-cube Examples and Code Snippets
Community Discussions
Trending Discussions on spinning-cube
QUESTION
I'm completely new to coding so any help would be of great value.
I am trying to get a cube (which is an imported FBX with materials) to spin when the collider enters the box collider of the cube. I have been following 2 tutorials to get me going. The first is a spinning cube, which I completed successfully and the second is adding sound/music to the game when a 'Trigger Zone' is entered, again, this was no problem.
I would now like the cube to spin when the trigger zone is entered, so I thought I would be able to combine the 2 and make it work, but after a good while I've come to a dead end. Due to my lack of understanding I have no idea why what I have written isn't working when the script is added to the cube.
The cube tutorial I followed - https://unity3d.com/learn/tutorials/topics/scripting/spinning-cube
The music tutorial I followed - https://unity3d.com/learn/tutorials/topics/audio/adding-music-your-game
And my unsuccessful attempt at a spinning cube based on combining the above -
...ANSWER
Answered 2017-Sep-07 at 21:08OnTriggerEnter
will be called once when an object enters the trigger.
OnTriggerExit
will be called once when an object exits the trigger.
If you want the object to keep spinning, you may want to try a different strategy.
OnTriggerStay
is another event that will be called roughly once per frame for each object that is currently within the trigger. This would allow you to call transform.Rotate
once per frame to keep spinning a little bit on each frame. This is a simple but brittle solution.
Unity is a "component-based" architecture -- each of your scripts is a component, and it's often advantageous to combine multiple components that work together. You could create one script that manages the spinning behavior in an Update
event that gets called once per frame, then create another component that enables and disables the spinning script based on trigger entry/exit.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spinning-cube
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page