• 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 TomatoOrgyLT · Oct 30, 2016 at 11:47 PM · movementteleportblocksroundgaps

NES Battle city like movement when turning (teleporting to fit through the gap of blocks without getting stuck)

This is what I'm talking about https://gyazo.com/20bd71273164bd1cfe0f276ecf83e690

As the title say i'd like to make my tank move through the gap smoothly without making the tank collider smaller. For example, if I'm moving right and I'd like to go through a gap between blocks with a pathway leading up, I would teleport in front a bit when the "up" key is pressed.

I was thinking about rounding the numbers using Mathf.Round but I have no clue how to implament that. Would really appreciate any sort of suggestions.

Comment
Add comment · Show 2
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 Sergio7888 · Oct 31, 2016 at 04:40 PM 0
Share

Remove your Square Collider of your tank and use a Circle Collider.
Or $$anonymous$$ake the square collider a trigger and add a Circle Collider for navigation.
Or use 2 objects in different layers in one you put her square collider for collide with bullets, in the other object you use a circle collider to collider with the walls, and change the collision matrix in Physics2D.

avatar image TomatoOrgyLT Sergio7888 · Nov 02, 2016 at 12:09 AM 0
Share

I suppose that would work, but I want is that choppy teleporting movement and circle collider does not provide that. It would just slide a bit reducing speed until it fits into the gap.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TomatoOrgyLT · Nov 02, 2016 at 12:12 AM

Here's an answer I was looking from a guy from youtube called Ivan Enzhaev

Snapping a tank is very simple. For example your tank has width = 32 and it is moving to right (x, y) -> (0, 0) -> (1, 0), (2, 0) -> .... When you press Up key you need to around X coord. For example, I created an array for X: 0, 16, 32 So If you move to right and pres Up key you need to add to Up key handler a calculation of X coord. For example: if X = 14 you need to set for X coord a value = 16

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 jmgek · Nov 02, 2016 at 12:54 AM

Don't use Colliders, make a 2D array and set each element to either 1 or 0, If the player moves check the array and if it's 0 don't lerp to that position, if its a 1 lerp the tank to that position. Also this gives you the ability to spawn the world, at startup check if the element is 0 and if so spawn your brick tile.

Try to stay away from any kind of physics!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

69 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

Related Questions

Trouble with Round Generating 0 Answers

How remove block mesh gap 1 Answer

Start new round after checking neighbors C# 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I stop player from moving after teleport? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges