0
Answered

Variable not Found

Steve 2 years ago updated 2 years ago 7

Hello, I'm trying to get a camera to follow a cube that is translate over time. But, I'm struggling quite a bit. Mainly though, when I get a game object variable, get it's position and then feed that into set position for the camera, I keep getting this error. I don't know if this is bad form, but I really am just trying to visually lay out:

transform.position = player.position + offset

Offset is the camera offset from the player or moving cube's position. What am i doing wrong?

Sorry to ask such low level stuff, but I'm just trying to build some kind of foundation.

Thanks,

Steve

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Pending Review

Hi Steve!

What this get variable unit is trying to do is get the variable called "HeroCubeObject" (second string port) defined on the object [HeroCubeObject] (first GameObject port). If you only need to access the object itself, you don't need to use Get Variable, you can just pass the object directly.

+1

Ahh, okay. I'll work on that! Thanks, Lazlo. :)

Alsoi keep an eye on the Graph inspector if you  haven't looked, red and yellow nodes usually point to what is missing.

Seems like I finally got it. Taking me some getting used to. But, quite nice so far!


Awesome!

Here's a tip for your graph: you don't need that first Set Position unit. You can connect the result of Get Position directly to the A port of Add. :) 

Another tip: you don't need to connect the flow ports for most nodes that just return a value. For example, here, you can connect Update directly to the last Set Position.

Okay, cool! I'll try that out. Yes, it seemed like I was using too many nodes. You will have to forgive another Playmaker comparison, but I'm just so used PM actions that carry a lot of weight for the user. This system seems more flexible in a way, but yeah... Still very much learning.