transform.position not Working,

In my FixedUpdate transform.position not working ,I am new to unity

My code

void FixedUpdate () {

if (Input.GetMouseButtonDown (0)) {

		Vector2 cubeRay = Camera.main.ScreenToWorldPoint (Input.mousePosition);

		RaycastHit2D cubeHit = Physics2D.Raycast (cubeRay, Vector2.zero);

		if (cubeHit.collider.name.ToString () == center.name.ToString ()) {
			string game = cubeHit.collider.name.ToString ();

			for (i = 0; i < gos.Length; i++) {
				if (gos *.name.ToString() == game) {*

gos.transform.position= Vector3.Lerp (gos_.transform.position,offer.transform.position,50Time.deltaTime);
System.Array.Resize (ref gos, gos.Length-1);
System.Array.Resize (ref texts, texts.Length-1);
System.Array.Resize (ref numbers, numbers.Length-1);*_

* }*

* }*
* for (i = 0; i < gos.Length; i++) {*
_ Destroy (gos );
* Destroy (offer);
}
for (i = 0; i < 3; i++) {
Destroy (stone);
}
score = score + 1;
Debug.Log (score);*_

* start();*

* }*
---------------------------
gos.transform.position= Vector3.Lerp (gos_.transform.position,offer.transform.position,50Time.deltaTime);
--------*

not working ,how to solve this ,_

You are not using Lerp correctly. Lerp returns a value interpolated between first and second parameter based on the third which has to be between 0 and 1 (0 100% first parameter, 1 100% second parameter). passing in 50Time.deltaTime gives you either a value constantly above 1 (which gets clamped down to 1), so the returned Lerp value is always the second parameter, or a fluctuating something in between hat where the result of 50Time.deltaTime results at, since deltaTime is not stable.
I don’t know what your intention is so I can’t tell you how to fix it.

I think destroy object or call start function tack place before transform.position in fixed update

Seems like there’s some basic concepts you are misunderstanding here. The code does execute in the order it is written so there’s no way the Destroy() or start() would happen before the Lerp.

The problem is though, just like @hexagonius explains, that Lerp just returns a Vector3 value, a single position, It doesn’t move anything smoothly.

The condition for all of this code is if (Input.GetMouseButtonDown (0)) which means it gets run exactly once when the mouse button registers a press. You have to call Lerp and set a new position over multiple Update() or FixedUpdate() calls or in a Coroutine in order to “animate” any kind of movement, [as shown in the manual for Vector3.Lerp()][1]. After you have changed the position enough times that the object is where you want it to be, call Destroy() and start()

Even if you changed the position gradually a 100 times in a for loop inside your FixedUpdate(), nothing would animate, the object would just appeaar to warp to destination. Unity can only draw the changes on the screen between Update() calls, your for loop (like any normal method in your monobehaviours) will execute during one Update()

With VisualStudio’s refactoring tool i moved most of the movement stuff into it’s own method and made it a Coroutine. This should give you an idea…

private void FixedUpdate() {

		if (Input.GetMouseButtonDown(0)) {

			Vector2 cubeRay = Camera.main.ScreenToWorldPoint(Input.mousePosition);
			RaycastHit2D cubeHit = Physics2D.Raycast(cubeRay, Vector2.zero);
			if (cubeHit.collider.name.ToString() == center.name.ToString()) {
				StartCoroutine(LerpObjectOverTime(cubeHit));
			}
		}
	}

	private IEnumerator LerpObjectOverTime(RaycastHit2D cubeHit) {
		string game = cubeHit.collider.name.ToString();
		Transform transformToMove = null;
		for (i = 0; i < gos.Length; i++) {
			if (gos*.name.ToString() == game) {*

_ transformToMove = gos*.transform;_
_
System.Array.Resize(ref gos, gos.Length - 1);_
_
System.Array.Resize(ref texts, texts.Length - 1);_
_
System.Array.Resize(ref numbers, numbers.Length - 1);_
_
}_
_
}*_

* if (transformToMove == null) {*
* yield break;*
* }*

* var percentMoved = 0f;*
_ var startPosition = gos*.transform.position;
while (percentMoved <= 1f) { // do this until we reach “100%” (1f)
// place the object between “startposition” and “offer.transform.position”
// “percentMoved” determines how much of the distance is traveled*
* transformToMove.position = Vector3.Lerp(startPosition, offer.transform.position, percentMoved);
percentMoved += 50Time.deltaTime; // increase the percent so that next time Lerp gives a result that’s closer to end position_

* yield return null; // and then let unity do other stuff so it can draw these changes on screen.*
* }*

* // percentMoved became greater than 1f and we exited the loop, now do these final things.*
* for (i = 0; i < gos.Length; i++) {*
_ Destroy(gos*);
Destroy(offer);
}
for (i = 0; i < 3; i++) {
Destroy(stone);
}
score = score + 1;
Debug.Log(score);*_

* start();*
* }*
_*[1]: https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html*_