Files
uni/third/semester1/CT3536: Games Programming/notes/_minted-CT3536-Notes/ADDC052D01797257AF6FE715AB9FD72DA97D9E8903456DD8DEC827D96A24153A.pygtex
2023-12-07 02:05:57 +00:00

17 lines
1.7 KiB
Plaintext

\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
\PYG{k}{public}\PYG{+w}{ }\PYG{k}{class}\PYG{+w}{ }\PYG{n+nc}{GameManager}\PYG{+w}{ }\PYG{p}{:}\PYG{+w}{ }\PYG{n}{MonoBehaviour}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{c+c1}{// inspector settings}
\PYG{+w}{ }\PYG{k}{public}\PYG{+w}{ }\PYG{n}{gameObject}\PYG{+w}{ }\PYG{n}{marsObject}\PYG{p}{;}
\PYG{+w}{ }\PYG{c+c1}{// Start is called before the first frame update}
\PYG{+w}{ }\PYG{k}{void}\PYG{+w}{ }\PYG{n+nf}{Start}\PYG{p}{()}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{n}{marsObject}\PYG{p}{.}\PYG{n}{transform}\PYG{p}{.}\PYG{n}{position}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{k}{new}\PYG{+w}{ }\PYG{n}{Vector3}\PYG{p}{(}\PYG{l+m}{0}\PYG{p}{,}\PYG{l+m}{0}\PYG{p}{,}\PYG{l+m}{0}\PYG{p}{);}
\PYG{+w}{ }\PYG{n}{Camera}\PYG{p}{.}\PYG{n}{main}\PYG{p}{.}\PYG{n}{transform}\PYG{p}{.}\PYG{n}{position}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{k}{new}\PYG{+w}{ }\PYG{n}{Vector3}\PYG{p}{(}\PYG{l+m}{0}\PYG{p}{,}\PYG{l+m}{0}\PYG{p}{,}\PYG{l+m}{100}\PYG{p}{);}
\PYG{+w}{ }\PYG{n}{Camera}\PYG{p}{.}\PYG{n}{main}\PYG{p}{.}\PYG{n}{transform}\PYG{p}{.}\PYG{n}{LookAt}\PYG{p}{(}\PYG{n}{marsObject}\PYG{p}{.}\PYG{n}{transform}\PYG{p}{);}
\PYG{+w}{ }\PYG{c+c1}{// before this can run, you need to manually add a rigid body with 0 angular velocity and no gravity in the UI}
\PYG{+w}{ }\PYG{n}{marsObject}\PYG{p}{.}\PYG{n}{GetComponent}\PYG{o}{\PYGZlt{}}\PYG{n}{RigidBody}\PYG{o}{\PYGZgt{}}\PYG{p}{().}\PYG{n}{addTorque}\PYG{p}{(}\PYG{k}{new}\PYG{+w}{ }\PYG{n}{Vector3}\PYG{p}{(}\PYG{l+m}{0}\PYG{p}{,}\PYG{l+m}{20}\PYG{p}{,}\PYG{l+m}{0}\PYG{p}{));}
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
\PYG{p}{\PYGZcb{}}
\end{Verbatim}