© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
2 replies
_arira_

❔ Having trouble with a player swap function

public void swap()
        {
            Vector3 LastPlayerPos = transform.position;
            transform.position = Clone.transform.position;                     
               Clone.transform.position = LastPlayerPos;

                    
        }
public void swap()
        {
            Vector3 LastPlayerPos = transform.position;
            transform.position = Clone.transform.position;                     
               Clone.transform.position = LastPlayerPos;

                    
        }

basically here i take the player position when the function is called and incorporate it in a variable (LastPlayerPos) Then i switch the player position with another gameobject (cloneposition) and swap the position of the clone with the lastplayerpos. It doesnt work tho, the clone teleport to the player but the player doesnt teleport to the clone. Does anyone know why?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ HAVING TROUBLE CALLING A FUNCTION
C#CC# / help
2y ago
Having trouble with classes
C#CC# / help
3y ago
Function that swap two numbers
C#CC# / help
3y ago