#Right after spawning the enemy put this
1 messages · Page 1 of 1 (latest)
'GameObject' does not contain a definition for 'location' and no accessible extension method 'location' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
hey its fine! i actually tried .position as well, but it gives the same error, but for position rather than location
Ah, enemy is of type GameObject, not Transform.
enemy.transform.position
It's the spawnLocation object that's a transform
Spawning an enemy at the position of Platform Spawn Checker (UnityEngine.Transform), which is (44.12, 2.54, 0.00). Enemy is at (20.23, 2.23, 0.00)
its the platform spawn checker, that is the transform, its where i want the enemies to spawn, so theyre essentially always offscreen, to the right of the player
you can see there that theyre not spawning at the current transform of the platform spawn checker
Does the enemy have any code in Awake?
yes actually, on thier spawn, they should always be to the right of the player
which turns out isnt happening either
Ah, so the initial spawn position is being overwritten
because the player object can move far past where theyre spawning
That value does look like it'd reasonably match up with the location it's getting
im gonna speculate here but are all the new prefab enemies that are spawning, not finding the player maybe and thus theyre just spawning all around x19
Where do you set Player for these objects
in the prefab
So, they're spawning at the position of the Player Prefab, which likely does not ever move
So they're spawning exactly where you tell them to
right so i need to set them to spawn relative to the game object (?) player if im understanding this correctly
Yes. You are already finding the object in the scene in start, use that instead of having a different variable that holds the player's prefab
ok cool, i've got this working now, thanks. what i've done is removed the "find player gameobject" line from the individual enemy script, as it was already finding the player script there anyway, and using the transform of the script rather than the play gameobject. once again, thanks a million.
u still using unity?