Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by dead_byte_dawn · Jan 30, 2016 at 09:31 PM · 2dmovementai

Trying to get a Circle Collider 2d to move around in a play area.

Super basic Game Jam Project: All I need is 2d (topdown) sprites with CircleColliders, to move around in an area of walls made from collider boxes. I've spent hours trying to solve and I'm stumped any help would be SUPER appreciated, even if somebody could just point me to the right documentation.

  • Start at Spawn Point

  • Move Right with a Random Y axis

  • Detect Wall and Stop

  • Pick a new X and Y then Move

  • Repeat.

This is what I have thus far(that works):

 public float moveSpeed = 1.0f;
 public Vector2 userDirection = new Vector2(-1,1);
 public float turnVelocity = 0.5f;
 public Transform moving;
 public GameObject movingTarget;



 void Start(){
     this.gameObject.transform.position = new Vector2 (-6, -1.5f);
     
 }
     
 void Update(){
     transform.Translate (userDirection * moveSpeed * Time.deltaTime);
     transform.rotation = Quaternion.identity;
     if (!moving) {
         Debug.Log ("HIT WALL");

     } else {
         Debug.Log ("MOVING");
     }
     }





Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DroidifyDevs · Jan 31, 2016 at 12:31 AM

1: To start at spawn point, simple move the object you're moving to the spawn in the scene editor. So if you want it at x = 1, y = 8, z = 6, then simply set it's position to those values, and when you load the scene it will start there.

2: You'll need to make controls. For simple controls this will do: http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player

I think transform.Translate is for mobile only, but not sure.

3: To detect a wall you can use a collider on your game object and set it to "trigger". The use the OnTriggerEnter to stop the object (http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dead_byte_dawn · Jan 31, 2016 at 01:36 AM 0
Share

Thanks, gonna try this out right now.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

72 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Making 2d grid movement 0 Answers

top Down 2D flight game AI 0 Answers

Making the AI move randomly around the player's last known location 1 Answer

keep a 2d sprite in an area via color 0 Answers

Unexpected symbol '=' parser error and Unexpected symbol '(' error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges