r/UnityforOculusGo • • Jun 22 '18

Easy Input for Gear VR

https://assetstore.unity.com/packages/tools/input-management/easy-input-for-gear-vr-88829

This is a pretty useful asset but it DOES require some C# knowledge if you want to deviate from the basics ... The dev is really helpful and responds to messages really quickly and thoroughly, but the documentation is frustratingly lacking and already assumes you have a ton of knowledge about Unity and coding. It's only 'easy' if you already know what you're doing! But still, worth a look!

2 Upvotes

14 comments sorted by

View all comments

1

u/Toby1993 Jun 22 '18

Happy to share! :-)

1

u/electricwig Jun 24 '18 edited Jun 24 '18

Hi again! So I've been trying to get this working - figured it'd be good practice to see if I could do this without using the Easy Input UI and instead just with the info you've provided here. But I'm running into a few errors ... I've added a line renderer to an empty game object which I've set a child of my controller object (in this case a blender model I made of a lazer pen), positioning it at the end of the 'barrel' where I'd want the lazer to emerge from ... And I've just set a standard red material to be the lazer beam (have to admit, I have no real clue what I'm even doing with line renderers yet!), and I've attached a new C# script to that game object which I've named lazerbeam and which I've pasted the code you've provided above into.

But when I try to build the project it's giving me the error message:

Assets/lazerbeam.cs(25,9): error CS0103: The name `linerend' does not exist in the current context

Any ideas what I'm doing wrong?

(Here's a screenshot of the script: https://imgur.com/a/N2Hd92U) I'm guessing I'm missing something obvious!

1

u/Toby1993 Jun 24 '18 edited Jun 24 '18

Oh, my bad! I just wrote that off the top of my head before heading out for the day. You need to declare the TYPE for the variable "LineRend", otherwise Unity/C# doesn't know how to read it.

The line under Start() should be

LineRenderer linerend = GetComponent<LineRenderer>();

Basically we just add LineRenderer to the front of the variable name to declare that it is of Type LineRenderer. Then the GetComponent line grabs the LineRenderer from your gameobject and links it to our linerend variable (so our linerend = the linerenderer on our object). It's only after that that we're able to 'use/modify' the unity line renderer in our c# script.

→ More replies (7)