- Home /
Question by
fevixlevix · Jul 16, 2020 at 04:49 PM ·
transformtransform.positionteleportchild object
how would the code be for the son of my game object to teleport to position 0.36,0,0 in relation to the center of my game object?
how would the code be for the son of my game object to teleport to position 0.36,0,0 in relation to the center of my game object? Thanks
Comment
Best Answer
Answer by HappyPixel27 · Jul 16, 2020 at 06:06 PM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Play : MonoBehaviour
{
public Transform parentObject;
[SerializeField]
Vector3 offset;
Vector3 offset_private;
public void FixedUpdate()
{
offset_private.x = parentObject.position.x + offset.x;
offset_private.z = parentObject.position.z + offset.z;
offset_private.y = parentObject.position.y + offset.y;
transform.position = offset_private;
}
}
I believe this should work for you.
Your answer
Follow this Question
Related Questions
How do I teleport the children to the coordinates 0.36,0.0 in relation to the father 1 Answer
how to make a bolt collision teleport player to where the collision happened 1 Answer
ping pong on x axis, unable to touch end of plane, 1 Answer
Need help updating camera position to go above the player 2 Answers
How do I get the transforms of all the objects in my scene ? 2 Answers