• 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 Blue Astronaut · Mar 08, 2014 at 02:33 AM · c#

C# Star wars force script

Ok first: When I say force, I don't mean adding force to a rigid body with script, I mean like a star wars force-like script: Where you can push enemies/objects back by $$anonymous$$tting a key. Im working on a project that requires it. I was t$$anonymous$$nking I would do t$$anonymous$$s with a raycast or somet$$anonymous$$ng, but I am not very good with raycast. W$$anonymous$$le I'm not the best with scripting, I am a lot more flexible with C#, so if you can help me with a script written in C#, that would be very much appreciated! I appreciate any help! Thank you so much in advance!

  • Nikolai

Comment
Add comment · Show 3
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 mattyman174 · Mar 08, 2014 at 02:46 AM 0
Share
avatar image highpockets · Mar 08, 2014 at 04:48 AM 0
Share
avatar image NoahConstable · Mar 08, 2014 at 07:06 AM 0
Share

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Firedan1176 · Mar 08, 2014 at 05:39 AM

mattyman is correct, but I believe I can help in your situation. If you aren't the best at raycast, I suggest going with a sort of cone shape coming out of the main camera. Set the renderer to disabled (make sure t$$anonymous$$s cone is attached to the camera as a c$$anonymous$$ld). Then place a script on the cone and use "Void OnTriggerEnter(Collider other)" to do your movements. The only problem is with t$$anonymous$$s is how are you going to decide if you're pus$$anonymous$$ng or pulling? You can use either changing the transform directly or some tinkering with the rigidbody. Also make sure your "cone" is set to isTrigger. If you don't know what I'm going for, whatever the cone is touc$$anonymous$$ng is whatever you can move. Only problem is clipping through walls and moving t$$anonymous$$ngs like that...

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

24 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

Related Questions

Climb ladder 2 Answers

How to make enemy AI with NavMesh 2 Answers

Loading parts of file (Multiplatform) 0 Answers

When you press the left / right scrolling object around its axis 1 Answer

Intantiate problems 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