Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Xtra Snipey · May 01, 2014 at 09:48 AM · boardgame

how can i set up a wall detection to enable down movement?

alt text

in this image, pacman is in a situation where he can go down.

is there a code that does this?

no wall> direction pad appears> click down/right> continue

hopefully this is understandable,

Thanks in advance!

help2.png (22.5 kB)
Comment
Add comment · Show 1
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 maroltl · May 01, 2014 at 11:01 AM 0
Share

this

i dont know if this is the most efficient way. try to find pacman tutorials on internet. I am sure that you can find something useful.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by KevLoughrey · May 01, 2014 at 11:10 AM

You could make a 2D array of bools (or some other datatype) to represent the map/grid, and set the grid tiles occupied by blocks to false. Then before you move pac-man all you have to do is get his current position in the array (x,y) and check if the tile beneath him (x, y+1) is false. If it is, you don't move.

To get his current array position you'd do something like dividing his x position by the grid tile width. Same for the y.

Edit: You could also use a 1D array if that's your preference.

Comment
Add comment · 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
0

Answer by sumeetkhobare · May 01, 2014 at 11:44 AM

use

 Physics.Raycast();

for every direction, up,down,left and right. by this detect walls, if wall, can't move, if not ,can move. I would say, whenever you move in any direction, don't move using this basic movement statement:

 transform.position = transform.position - Time.deltaTime *Speed;

I suggest.. whenever a direction key is pressed, move a particular distant in that direction , no matter what, like 1m.even if other key is pressed. this will make your player hard to manage themselves in tight spots, but at least that will save your character from getting stuck in wall and the road.

use,

  Vector3.Lerp

to lerp between distants or move direct. Mark Question solved, if the problem is solved.

Comment
Add comment · 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

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

22 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

Related Questions

A node in a childnode? 1 Answer

How to implement a board game movement. 2 Answers

Finding Edges 1 Answer

whats a mathf.round 2 Answers

Making sprites 2 Answers


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