Answered Scripts - moving CUA?

Jiraiya

Well-known member
Messages
480
Reactions
999
Points
93
Ok, so I can move the transform inside the CUA, however that does strange things because it ends up off center to the placed CUA atom, while useful this isn't what I need right now.
I need to move the whole asset as if you manually dragged it yourself.
I am struggling to understand how to access the position of the atom from within the script applied to that atom.
 
I need to move the whole asset as if you manually dragged it yourself.
You mean the "control" node of the CUA? That's the green icon thingy of an atom, a green square in case of the CUA.

If you are in your plugin code (MVRScript class), try one of these....they are literally equivalent:
GetMainController().transform containingAtom.mainController.transform

With the transform you can get/set the position and various other helpful things:
.position .rotation
Or setting both at the same time (which is slightly faster than setting one after the other):
.SetPositionAndRotation(Vector3 position, Quaternion rotation)

If you need an example, check out LogicBricks LinearAnimation, as that is a nice and simple plugin.
 
Upvote 0
Thanks, I will try that out. containingAtom.mainController.transform sounds like what I want.
I was going to ask about keeping movement constant despite FPS variation, but I managed that just by using the ms timer, so it never goes faster than it should even when you go to 120fps etc.
Next is to work out how to increase the speed of movement at lower than desired fps by skipping steps. Ideally the movement will appear constant speed to the user whatever their fps goes to.
 
Upvote 0
but I managed that just by using the ms timer,
A millisecond timer isn't precise enough. You should multiply your movement distance by Time.deltaTime. That's the time in seconds since the last frame (= 1 / FPS) , meaning your values are then in meters per second. If you happen to do stuff in the physics update (inside the FixedUpdate method), use Time.fixedDeltaTime instead.
 
Upvote 0
Thanks! (again!)
Those changes worked perfectly. Now the actual in game control point moves with the asset, instead of it's "home" point staying still and the visible object moving away from it. (horrible!).

Now I just have to work out how to detect the "freeze movement and animation" tick box, because my script ignores that!
 
Upvote 0
Back
Top Bottom