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 Overflo · Sep 20, 2012 at 06:45 AM · 2.5dsidescroller

advice on how to implement 2.5D

I am doing a group project as an assignment. We are making a 2.5D sidescroller (Please don't ask me why, not my decision) Anyway I am new to unity so I don't want the code, just a point in the right direction on the best way to implement the following.

The character moves along the x plane (obviously) but there are 3 of these (apparently it is similar to the game Little Big Planet).

At certain points (I have named these crossPoints) the player can cross to the adjoining plane. So the player can move with the forward and back arrows and nothing happens if pressing the up and down, unless he is parallel to the crossPoints (think doors). In that case he will move to the other plane.

If in the middle plane I need to know which side of the player the crossPoint is on (i.e. - or + I guess).

What is the best way to implement this? Is it with colliders (if so, how do I know which side?) or is there a better way.

Any advice is greatly appreciated, I'm here to learn as much as i can.

Cheers

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
1
Best Answer

Answer by Fattie · Sep 20, 2012 at 07:53 AM

2.5D ... "Please don't ask me why, not my decision" LOL !!!!

  • if you really mean 2.5D, 2.5D games in Unity are very often made with 2DToolkit. get it in the app store. (it would be an astoundingly, completely ridiculous waste of time, to write 2 man years of code to handle sprite sheets, etc) other similar competing packages exist too

  • just FTR as far as I know Little Big Planet is an entirely 3D game (you see all the models in 3D, not orthographic), it just happens that the camera is usually at one side

  • ...the x plane (obviously)... in Unity if you are standing up at the racetrack looking forwrd. x and y are exactly like in junior high geometry. Y is up and X is to your right. z is forward. it is a "z forward" universe. you will say this phrase 900 billion times in your career. you hire someone to make some models, you tell them "don't forge it must be z forward"

  • typically you do a 2.5D game in the XY plane. ie standing up. (so that gravity works of course) so the action happens at z=fixed value. if by "x plane" you meant the "YZ" plane that is not really right, you do it in the z plane (ie, the XY, upright, z=0, plane)

  • i say typically in the sense of "you basically must do it that way, there is no other possibility" :-) so if you've done the game laying down or sideways, you'll have to change it immediately before going further

your question ......... you will have to draw a diagram. it's confusing.

but I think all you hae to do is simply look at the position of the hero. so that's hero.transform.position.x. if that value is less than 12.45 (or whatever) you know he is on one side, if more than 12.45 he is on your other side. it's that simple.

(note that I say x because x is moving left and right in a 2.5D side scroller. y is moving up and down - exactly like drawing a cartesian graph in junior high .. on the iPad screen, x is left and right and y is up and down)

a collider .. those do not really let you know WHERE SOMETHING IS, more WHEN IT ENTERS AN AREA. makes sense?

to find out "where something is" you incredibly simply define an area (I mean like "x is between 1.2 and 1.87" and "y is between whatever") and then you use an "if" statement to see if the thing is in that area.

in fact often you'd simply have a tiny script (one line) attached to the object that constantly sets a boolean, in or out of area. then at any moment you can just say isItInsideThe.danegrZone at any time.

if you need more than this, need a diagram !!


you asked for actual code!

say you have a DOG and you want to know which side it is from a TREE. ok?

 var DOG:Transform;
 var TREE:Transform;
 var distanceToRight:float;
 distanceToRight = DOG.position.x - TREE.position.x;
 
 if ( distanceToRight > 0.0 )
   Debug.Log("the dog is on the right of the tree !!");
 else
   Debug.Log(the dog is left of the tree.");


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 sanderman0 · Sep 20, 2012 at 09:06 AM 0
Share

If by left and right you mean on the y-axis.. Then just compare the two y positions of the objects. If a.y < b.y then you know a is to the left of b. If not, then to the right. Another approach is taking the sign of the difference. $$anonymous$$athf.Sign(b.y-a.y) returns 1 if b is to the right of a and -1 if b is to the left of a. The sign is not really needed here but can be useful for later calculations.

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

11 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

Related Questions

Knockout Or Suicide Detection 1 Answer

Water volume for Sidescroller 1 Answer

Underwater 2.5d scroller 3D model Rotation 0 Answers

Input.GetAxis to act like button 1 Answer

Isometric 2.5D RPG: Advice 7 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