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 /
  • Help Room /
avatar image
0
Question by cyper43 · May 31, 2016 at 07:37 PM · newbieprogramming-basics

RTS like development help

Hi, im doing a project for college with the theme "social network". But social network is so bland for my taste, so i thought i could "spice" things up with a rts like game that would be influenced by the number of "likes/dislikes" of posts. The web part is more or less finished but since i never programed in c# before im kinda in a pinch. how do i make a clickable building that would trigger a ingame window with the building stats? Thanks in advance

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

Answer by Soos621 · May 31, 2016 at 08:13 PM

You want to do something like this

Public Camera playerCam;

void Update (){ If(Input.GetMouseDown(0)){ OnMouseClick (); } }

void OnMouseClick (){ RaycastHit camRayHit; If(Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out camRayHit, 1000)){ If(camRayHit.collider != Null){ If(camRayHit.collider.GetComponent()){ //Hit object is building } } } }

I apologize for the format I am on a mobile device

Comment
Add comment · Show 4 · 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 cyper43 · Jun 01, 2016 at 07:52 AM 0
Share

Thank you, but in what object should i attatch this script to? camera or the building?

avatar image Soos621 · Jun 01, 2016 at 02:17 PM 0
Share

What I usually do is attach the script to the players gmeobject and then just have a reference to the camera but if the player object is the camera then that's fine too

avatar image cyper43 · Jun 01, 2016 at 02:22 PM 0
Share

The game will be a isometric rts like game with no character, like travian where the player can click the buildings to upgrade them. So thenobjdctive would be on building click to popup a window with the building stats and upgrade cost.

avatar image Soos621 · Jun 01, 2016 at 02:28 PM 1
Share

ok then. I would also suggest looking into interfaces it will allow you to click different objects without having to re-code scripts (Example: if you have units and buildings that you wanted clicked you can use a interface to make them both "clickable") just food for thought

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

58 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

Related Questions

Multiple OnTriggerEnter but each in different scripts 1 Answer

Newbie trying to undestand unity 1 Answer

How to get the camera to follow a prefab? 2 Answers

Help! I don't know how to fix this. Errors CS1041, CS1525, CS8025 1 Answer

Help with first project. 1 Answer


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