Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CellToLocalInterpolated(Vector3)

Converts an interpolated cell position in floats to local position space.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.GridModule
public Vector3 CellToLocalInterpolated(Vector3 cellPosition)

Parameters

cellPosition

Interpolated cell position to convert.

Returns

Type

Description

Vector3Local position of the cell position.

Remarks

Returns the local position in floats.

Examples

// Snap the GameObject to parent GridLayout center of cellusing UnityEngine;public class ExampleClass : MonoBehaviour{ void Start() { GridLayout gridLayout = transform.parent.GetComponent<GridLayout>(); Vector3Int cellPosition = gridLayout.LocalToCell(transform.localPosition); transform.localPosition = gridLayout.CellToLocalInterpolated(cellPosition + new Vector3(.5f, .5f, .5f)); }}