Topic: How to make buttons in Maratis
Hi, everyone
I know that there are some discussions about how to make buttons in Maratis. Unfortunately, after doing some search and test, I still can't create buttons using rayHit (sorry for my noobiness ). So I tried to follow this tutorial about getUnProjectedPoint but I got stuck again.
In my scene, I have three buttons: moveLeft, rotate, and moveRight. I want to use those buttons to move and rotate a cube.
Following the tutorial, I can make the rotation button to rotate the cube. However, when I moved the mouse cursor over the other buttons (moveLeft and moveRight), the cube also rotating. Can someone give me a hint of how to fix my script?
Here is the project file to download. https://www.dropbox.com/s/wzh0ioat20q8v
r_test.zip
And here is the script based on the documentation:
moveRight = getObject("moveRight")
moveLeft = getObject("moveLeft")
Rotate = getObject("Rotate")
Cube = getObject("Cube")
Camera = getObject("Camera")
point = getUnProjectedPoint(Camera, vec3(x, y, z))
function onSceneUpdate()
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")
V1 = getUnProjectedPoint(Camera, vec3(mx, my, 0))
V2 = getUnProjectedPoint(Camera, vec3(mx, my, 1))
point, Rotate = rayHit(V1, V2)
if point then
rotate(Cube, {0, 0, 1}, 4)
end
--[[
if point then
translate(Cube, {1, 0, 0}, 2)
end
]]--
end
Thanks for any help.