Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | olivier jeannel |
Hi there
in a PoolVector2Array( [Vector2(x,y)] )
I’d like to modify the second element (y) [1] only
How do I specify the second element in GD Script ?
Here’s my code :
var vecTrack = PoolVector2Array( [Vector2(0, 0)] )
func _ready():
vecTrack.push_back(Vector2(0,10))
vecTrack.push_back(Vector2(0,200))
func _process(delta):
#Get Point on track
var fOffset = 0.0
var nTrackSection = 0
#Find Position on track
while (nTrackSection<vecTrack.size() && fOffset<= fDistance) :
fOffset+=vecTrack[nTrackSection].second
nTrackSection +=1
fTargetCurvature = vecTrack[nTrackSection-1].first
. second and .first was an atempt to tell GD to access the first[0] or the second[1] element
Thank you !
Your code is very hard to read - please format it properly. 4 spaces or use the formatting button in the editor.
kidscancode | 2019-05-24 16:10
I apologies for the bad formating, I did use the formating button, for some reason it only formated one part.
*** I edited my original post
olivier jeannel | 2019-05-24 16:25