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 moonpix · May 06, 2012 at 02:06 AM · space shootercrosshairtargeting

Question about a space shooter crosshair targeting script

I've been trying to figure out how the following game's mouse targeting mechanics work: http://www.matteley.co.uk/labs/unity3d-spacerunner/

I managed to find a similar script on unityAnswers, but it doesn't have the same feel Space Runner provides where you're pretty much pulling on the crosshair, or at least that's how I interpret the feel.

Anybody have any idea how this can be accomplished?

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 moonpix · May 07, 2012 at 03:25 PM 0
Share

Actually, here's a great tutorial on how to do what I'm looking for. Just fix up the code to your needs. Enjoy people, guy deserves at least a like.

http://www.youtube.com/watch?v=39vaHGpwrRI&list=PL758D41DE629781C4∈dex=64&feature=plpp_video

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jacek_Wesolowski · May 06, 2012 at 02:52 PM

It looks like there are four objects placed in 3D space in front of the camera. Each can only move on a plane that's always parallel to the sceen. Also, each of the four planes is in a different, but constant distance from the camera.

The four objects are: the spaceship, the green rectangle, the crosshair, and an invisible "cursor".

The cursor moves around freely, just like an ordinary mouse cursor. It is, in fact, the mouse cursor, only translated into 3D space. It has no delay or drag, but you can't see that, because the cursor remains invisible.

The ship follows the cursor with a delay. You can create this kind of effect using the Lerp() function. The other two objects are always set to stay on an invisible line connecting the middle of the ship and the "cursor". Also, all three visible objects are always facing the "cursor". This can be achieved using the LookAt() function.

The hard part is moving an object around without allowing it to leave its designated plane. The simplest (but also quite limiting) way to do this is to assume the camera is moving along one of global axes - say, the z axis. Then all you need to do after lerping the ship and the crosshair is to reset their transform.position.z to some constant value of your choice, relative to camera's own transform.position.z .

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 moonpix · May 06, 2012 at 08:52 PM 0
Share

$$anonymous$$aybe this is what I'm looking for:

http://answers.unity3d.com/questions/185346/rotate-object-to-face-mouse-cursor-for-xz-based-to.html

Having a little trouble understanding it though.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

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

How to select only the enemies in a range as targets 2 Answers

how to create color targeting script for a 2d sidescroll 2 Answers

Character doesn't stop and sits on top of target. 1 Answer

Combat Script 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