Hi everbody I want to ask you about Example of a script that allow to my cube to move not to translate
and please if you can write it with java script thank you
any answers please help me
SomebodyWriteCodeForMe code = new SomebodyWriteCodeForMe ();
That should do it
There is a RotateAround function
So you can have four offset positions for four directions you move. You’d have to store the current rotation point temporarily until the rotation is complete, otherwise the position will change during the rotation.
Also when you complete the rotation I might round off the position to the spacing of the grid so you don’t introduce cumulative floating point errors. (If it’s important to stay on a grid.)
any script please
No one is simply going to write an entire script for you. If you try and need help then we show you what you’re doing wrong or missing but you haven’t even attempted to try and script it yourself.
The user above showed you a link to the documentation for the function you’ll need to use; he also told you a way to use it.
You need to go learn the basics. Give it a go yourself. If you’re still struggling then; come back and we’ll help you out. You need to meet us half way
You need to rephrase the question
“allow to my cube to move not to translate”
“i want to make my cube rotate translate and controlled by the user”
???
Look into this. Learn the basics. Do every module in the learn section.
write you are write i miss the basics but i have to learn it thank you so much i really apreciate
Oh, I hadn’t watched it past 23 seconds, so I assumed you wanted it to roll over, but when I watch the later part of that video I realize I don’t understand what you want at all.
i want to make my cube rotate translate and controlled by the user just Like the tutorial Rolle The Ball
Did you watch the tutorial series? You should be able to do what you’re asking if you watch it…
Well if there’s already a tutorial, we’re not going to be any better than that.
I would have guessed the difference between rolling a ball and rolling a cube is the cube rotates along the forward edge while the ball always rotates in the centre, which is why I mentioned the RotateAround function so you could change the rotation point.
So you inspired me to think of what game could be made with a rolling cube:
http://gamejolt.com/games/puzzle/dice-roller/30941/
So I had two Vector3, rotPoint and rotAxis. I had a float called rollingCount and a bool called rolling.
In Update, if rolling is false then I do GetKeyDown on four direciton keys.
If one of them is pressed, then I:
- set rolling to true (so I can’t start a new roll until this roll is complete)
- set rollingCount to 90 (it needs to rotate 90 degrees)
- set rotPoint and rotAxis depending on which direction it is
So still in Update, if rolling is true, then I
- use transform.RotateAround(transform.parent.TransformPoint(rotPoint),rotAxis,rotationSpeed);
- subtract rotationSpeed from rollingCount
- if rollingCount <=0 then I round off the position to the nearest 1 and the eulerAngles to the nearest 90, and set rolling back to false
thank you