19 lines
1.2 KiB
Plaintext
19 lines
1.2 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}{ExampleScript}\PYG{+w}{ }\PYG{p}{:}\PYG{+w}{ }\PYG{n}{MonoBehaviour}
|
|
\PYG{p}{\PYGZob{}}
|
|
\PYG{+w}{ }\PYG{c+c1}{// Launches a projectile after 2 seconds}
|
|
|
|
\PYG{+w}{ }\PYG{n}{Rigidbody}\PYG{+w}{ }\PYG{n}{projectile}\PYG{p}{;}
|
|
|
|
\PYG{+w}{ }\PYG{k}{void}\PYG{+w}{ }\PYG{n+nf}{Start}\PYG{p}{()}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
|
|
\PYG{+w}{ }\PYG{n}{Invoke}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}LaunchProjectile\PYGZdq{}}\PYG{p}{,}\PYG{+w}{ }\PYG{l+m}{2f}\PYG{p}{);}
|
|
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
|
|
|
|
\PYG{+w}{ }\PYG{k}{void}\PYG{+w}{ }\PYG{n+nf}{LaunchProjectile}\PYG{p}{()}
|
|
\PYG{+w}{ }\PYG{p}{\PYGZob{}}
|
|
\PYG{+w}{ }\PYG{n}{Rigidbody}\PYG{+w}{ }\PYG{n}{instance}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{Instantiate}\PYG{p}{(}\PYG{n}{projectile}\PYG{p}{);}
|
|
\PYG{+w}{ }\PYG{n}{instance}\PYG{p}{.}\PYG{n}{velocity}\PYG{+w}{ }\PYG{o}{=}\PYG{+w}{ }\PYG{n}{Random}\PYG{p}{.}\PYG{n}{insideUnitSphere}\PYG{+w}{ }\PYG{o}{*}\PYG{+w}{ }\PYG{l+m}{5f}\PYG{p}{;}
|
|
\PYG{+w}{ }\PYG{p}{\PYGZcb{}}
|
|
\PYG{p}{\PYGZcb{}}
|
|
\end{Verbatim}
|