For i in t[1,2,3,4,5] .

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ramazan
onready var pawn = preload("res://Sahneler/Krktr_shnlr/Dusmanlar/Piyon_birs.tscn")
onready var menu = get_tree().current_scene

func pawn_instance(a):
  var p = pawn.instance()
  menu.add_child(p)
  p.transform.origin = a.global_transform.origin
pass

# Note : $p1/$p2/... = Node name = Position3D
# Only the "X" coordinates of "Position3d" s change

func pawn_complete_instance():
  var t = [$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10]
  for i in t:
	  pawn_instance(i)
  pass
###### no problem working ######

#But
#How do I make the positions of the "pawn" scene in the bottom "func" 
#instead of adding "position3d". My aim is not to force the CPU
func pawn_complete_instance_two():
   var test_subject = [9, 7, 5, 3, 1, -1, -3, -5]
   var a : int
   var b = Vector3(a,0,0)
   for c in test_subject:
	    ........?
	pass

My aim is to write “func pawn_complete_instance_two():” similar to this. With this “func pawn_complete_instance():” will do the same thing

I’d like to help but this question, at least to me, wasn’t legible. Could you edit it to have the following please?

Change the title to concisely describe what your question is.

Add a fuller description of what your problem is at the top.

Highlight the code and click the curly braces so that it is properly formatted like this:

func example_method():
    return

Replace the variable names with meaningful English language ones. I’m sure “topu_gel” means something to you, but not to me and other users here.

Make the image viewable.

Thanks

DaddyMonster | 2022-01-16 15:45

Sorry, I tried to fix it a bit. But I couldn’t find the question title

OK I did it. Thank you very much for your interest

func pawn_complete_instance_two():
   var test_subject = [9, 7, 5, 3, 1, -1, -3, -5]
   var b = Vector3(0,0,0)
   for c in test_subject:
	   b.x = c
	   pawn_instance(b)
	
    pass

ramazan | 2022-01-17 08:09

:bust_in_silhouette: Reply From: DaddyMonster

Thanks for sorting the formatting and other things.

Your question is: How do I make the positions of the “pawn” scene in the bottom “func” instead of adding “position3d”. My aim is not to force the CPU

If I understand correctly, you are spawning objects and you’d like help setting their positions. So far you have:

func pawn_instance(a):
    var p = pawn.instance()
    menu.add_child(p)
    p.transform.origin = a.global_transform.origin

func pawn_complete_instance():
    var t = [$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10]
    for i in t:
        pawn_instance(i)

Here you have an array of child nodes and you’re using their position to spawn a new set in the same location.

If I understand correctly, in your second method it looks like you want to use the values in the array test_subject to set the position on the x axis of the spawned objects.

If I haven’t misunderstood, this is the solution:

func pawn_instance(a):
    var p = pawn.instance()
    menu.add_child(p)
    p.global_transform.origin = a

func pawn_complete_instance_two():
    var test_subject = [9, 7, 5, 3, 1, -1, -3, -5]
    for c in test_subject:
        pawn_instance(Vector3(c, 0, 0))

Definitely thank you for your help.

ramazan | 2022-01-17 11:54