'Make a object follow another object to scale

I'm making a vr game and want a 3d minimap. I have a script for a object to follow another object with distance with a 1 to 1 scale.

What i want is that if my player moved +1 on the x axes than my capsule moves 0,1. So something like the player position x 0,1 = capsule position. I want my Y posision to be always the same. I'm pretty new to this so i'm using a lot of help from google.

This is the code that i have now:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class minimapplayer : MonoBehaviour
{    public Transform leader;
    public float followSharpness = 0.1f;

    Vector3 _followOffset;

    void Start()
    {
        // Cache the initial offset at time of load/spawn:
        _followOffset = transform.position - leader.position;
    }

    void LateUpdate () 
    {
        // Apply that offset to get a target position.
        Vector3 targetPosition = leader.position + _followOffset;

        // Keep our y position unchanged.
        targetPosition.y = transform.position.y;

        // Smooth follow.    
        transform.position += (targetPosition - transform.position) * followSharpness;
    }
}


Solution 1:[1]

You can constantly store the last player position,
and then move the object based on the difference between the old and new position, scaled

public class FollowObj : MonoBehaviour {
    [SerializeField]
    private float followScale;

    // Yoor follow reference, assign it
    private Player playerRef;

    private Vector2 lastPlayerPos;

    private void Start(){
        lastPlayerPos = playerRef.transform.position;
    }

    private void Update(){
        Vector2 newPlayerPos = playerRef.transform.position;

        // Get a heading that points to the new position
        Vector2 playerTravelVector = newPlayerPos - lastPlayerPos;

        transform.position += playerTravelVector * followScale;

        lastPlayerPos = newPlayerPos;
    }
}

Solution 2:[2]

Try with this

TextField(
  inputFormatters: [
            FilteringTextInputFormatter.allow(RegExp("^[\u0000-\u007F]+\$"))
    ])

Or you can try with this if you want only english character.

 TextField(
   inputFormatters: [
            FilteringTextInputFormatter.allow(RegExp("[a-zA-Z]"))
       ])

Solution 3:[3]

TextField(
    inputFormatters: <TextInputFormatter>[
       FilteringTextInputFormatter.allow(RegExp('[a-z A-Z 0-9]'))
    ],
)

Solution 4:[4]

You can use regular expressions of english

bool validEnglish(String value) { 
  RegExp regex = RegExp(r'/^[A-Za-z0-9]*$'); 
  return (!regex.hasMatch(value)) ? false : true; 
}

TextFormField(
              decoration: InputDecoration(
                hintText: 'Enter text',
              ),
              textAlign: TextAlign.center,
               validator: (text) {
                if (text == null || text.isEmpty || !validEnglish(text)) {
                  return 'Text is empty or invalid' ;
                }
                return null;
              },
            )



    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaynnc
Solution 2
Solution 3 Amroun
Solution 4 Mudasir Syed