Create movable camera first person

Hey,
How can I add C# script (like PlayerController) on component and have render in web ?

Original Post on Discord

by user 191204280198234122

Hey @Ilaan

you can add a C# component to any of your objects but you have to write the code in javascript/typescript. You can read about it here: Needle Engine Scripting | Needle Engine Documentation

We dont export any C# code directly to the web but instead export all the component data in Unity

Oh okay I just need code in ts on c# file

by user 191204280198234122

In c# script

by user 191204280198234122

And I can use an event listener ? For pick event from keyboard

by user 191204280198234122

Yes, you just need a matching Typescript class (for example when your component is named MyScript.cs (aka MyScript : MonoBehaviour) you need a typescript class with export class MyScript extends Behaviour

Okay I understand I’m going to try

by user 191204280198234122

Yes you can use the browser events e.g. on window.document or this.context.domElement. There is also this.context.input (this context is assigned on any typescript component)

The code in the browser is basically regular webdev - you can do anything you can do when coding a normal javascript website too

(meaning you can also use any frontend framework too, for example web built our website using vuejs + needle engine)

Let me know if you get stuck somewhere :slightly_smiling_face: happy to help

Thanks you very much!! Yes I tell you

by user 191204280198234122

There’s also some information on here if you’re more familiar with Unity: needle-engine-support/documentation/for-unity-developers.md at main · needle-tools/needle-engine-support · GitHub

And if you want to have a look at samples/code we’ve written you can have a look at the repositories linked here: needle-engine-support/documentation/samples-and-modules.md at main · needle-tools/needle-engine-support · GitHub

or click on these blue links - they will open the typescript component :slightly_smiling_face:
unknown.png

Yes I have already view example ! Thanks you

by user 191204280198234122

I dont understand how i can write ts in cs file,
Have you any exemple I dont fount scripts in exemples

by user 191204280198234122

I see i can make it in react but my scene is already generated with three

by user 191204280198234122

And i’m new on threejs :confused:

by user 191204280198234122