[solved] object physical position vs atom position

Hyde's VR

New member
Messages
2
Reactions
1
Points
3
Hello everyone,

I've been trying to code some plugin script for an idea that I got but I couldn't find how to do this:

When getting the position of an object, it is the "Atom Control" position Vector3 coordonate. Which if I am understanding it right, is the defined location by the user (moved with the 3 color arrow and all that).
How to obtain the "Physics Object" position of that Atom, the current actual physic location while it is being pushed around and interacted with ?

I've tried differents methods, but every time I only get the atom position (FreeControllersV3.mainController property, or via the rigidbody object position "mainController.GetComponent<Rigidbody>()".
What am I doing wrong, and is it even possible ?

The test I've made is quite simple:
Created a ISSphere, create a CycleForce that is applying force to the sphere.

Thank you very much, the content of this community always impress me.
I haven't posted content yet, mostely because its quality not good or just very wierd and would make me unconfortable to publish.
But I may consider if my quality and wierdness improves.

Hyde's VR

PS: Sorry if my question is stupid, I've never coded with Unity. please be patient with me.
 
C#:
using System;
using UnityEngine;

namespace SPQR {
    public class TestPosition : MVRScript {
        
        public override void Init() {}
        void Start() {}
        void Update() {}

        void FixedUpdate() {
            DebugPosition(containingAtom);
        }

        void DebugPosition(Atom a)
        {
            Vector3 controllerPosition = a.mainController.transform.position;
            Rigidbody rb = a.GetComponentInChildren<Rigidbody>();
            Vector3 rigidbodyPosition = rb.position;
            SuperController.LogMessage(controllerPosition.ToString() + " vs " + rigidbodyPosition.ToString());
        }
    
    }
}
 
Thank you very much for your very quick and complete answere.,

I noticed, with the help of AcidBubble's GameObjectExplorer plugin, that the position I was looking for was there in some sub object and I came up with this ugly code before I noticed your answer :
C#:
foreach (Transform child in containingAtom.mainController.transform.parent)
{
    if (child.name == "object")
        ObjectTransform = child;
}

Your method is looking much better, I will use the "GetComponentInChildren<RigidBody>();" as you recommand

I was close but not quit there, I have so much things to learn.

thanks a lot.
 
Back
Top Bottom