Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with my 3D project?
- MarpMorp
- Scratcher
15 posts
Help with my 3D project?
I need an object to look at the player but I can't figure out how to do it.
Last edited by MarpMorp (Dec. 7, 2021 03:23:21)
- Jareddddddd
- Scratcher
1000+ posts
Help with my 3D project?
normally, i would use a 2d environment to help control the fine details like collision and casting. I'm not really good with actual 3d though (my attempts are like 2.5d)
- adem_1000
- Scratcher
84 posts
Help with my 3D project?
i can help out with that
this script will work for objects and camera
if y+ is the front of the camera and z+ is the top of the camera if the cam rotation x and camera rotation y is 0'
then use this:
the variables:
this script will work for objects and camera
define point to x:(x) y:(y)z:(z)it works only if z+ is the front of the camera and y+ is the top of the camera if the cam rotation x and camera rotation y is 0'
set [rotation x v] to (round (((180) * <<(Z) > (z)> or <(Z) = (z)>>) + ([atan v] of (((X) - (x)) / ((Z) - (z))))))
set [rotation x v] to (round (((180) * <<(Z) > (z)> or <(Z) = (z)>>) + ([atan v] of (((Y) - (Y)) / ((Z) - (z))))))
if y+ is the front of the camera and z+ is the top of the camera if the cam rotation x and camera rotation y is 0'
then use this:
define point to x:(x) y:(y)z:(z)
set [rotation x v] to (round (((180) * <<(Y) > (y)> or <(Y) = (y)>>) + ([atan v] of (((X) - (x)) / ((Y) - (y))))))
set [rotation x v] to (round (((180) * <<(Y) > (y)> or <(Y) = (y)>>) + ([atan v] of (((Z) - (z)) / ((Y) - (y))))))
the variables:
(X) (Y) (Z)just is the position of the object wich should point to that xyz point
Last edited by adem_1000 (Dec. 7, 2021 05:01:43)
- Discussion Forums
- » Help with Scripts
- » Help with my 3D project?