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 /
avatar image
0
Question by Mr.Capture · Jun 29, 2011 at 04:25 AM · 2dcrosshairworldtoscreenpoint

Worldtoscreenpoint.....

I'm trying figure out how go about doing a crosshar for my game. My game is 2d side scroller. I got the cross hair working easy enough, but I'm confused about the whole camera.worldtoscreenpoint and ray casting. I don't understand it or rather a method to apply it. if any one knows a tutorial on subject or book please lead me in right direction. I not asking for hand me out. I'll put time in learning it and I've googled it about three hours now, but I just silly questions on Unity answers.....Kind like my silly question haha.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by testure · Jun 29, 2011 at 05:35 AM

Specifically what are you trying to do? You're going to need to give us more information, because you've asked what something does- but you mention raycasting in the same sentence, and WorldToScreenPoint has nothing to do with raycasting- which is probably why you can't find any information about it.

Since you asked though, WorldToScreenPoint returns the screen coordinates of an object. Simple as that. If you have a character running around on screen, his 3D position might be (405.72, 88.91, 65.98), but on screen he will have an XY position that fits within your game's resolution. 0,0 being the bottom left corner of the window, and the top right being whatever the max width and height of the resolution is.

So specifically, what are you trying to do? A liero style side scroller, where you run around and use the mouse to aim/shoot? If that's the case, you dont' need to raycast at all, you can just measure the angle (in screen space) of the player's position on screen with the mouse, and get the dot product. You can also simply transform your mouse coordinates into 3D space and just set the missing axis to match whatever your player's is.

Without anymore info, it's all just speculation though.

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 Mr.Capture · Jun 29, 2011 at 06:01 AM

First I apologize about the confusion and thanks for summing up WorldToScreenPoint for me. Basically my idea is to shoot enemy's that are coming at the main character. you have to protect him. I'm using a cannon that you control. I basically just want it as to wherever my cross hair is my cannon ball will fire that direction so I have to figure like you said which would be the best solution though I was think of WorldToScreenCoord considering the cross hair on the mouse, but I have never fooled with raycasting either. In nut shell wherever my mouse is on the screen I need a cannonball to be fired at that location.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

screen coord 1 Answer

Inaccurate WorldToScreenPoint 0 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

2D Aiming with a mouse angle problem 1 Answer

Drawing crosshairs and other 2D graphics onto the screen? 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