• 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
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 hitting a key. Im working on a project that requires it. I was thinking I would do this with a raycast or something, but I am not very good with raycast. While 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

People who like this

0 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

UA is not the place to ask for Scripts to be written for you. If you have a specific question or are stuck on something specific while you are writing a script yourself, then we can help you.

avatar image highpockets · Mar 08, 2014 at 04:48 AM 0
Share

May the force be with you

avatar image NoahConstable · Mar 08, 2014 at 07:06 AM 0
Share

Although I agree with them that this is not the correct place for your answer, I think I know how this could be done (Besides what FireDan said). But I want to know, what are you doing besides AddForce? You said you don't want it, but how else will it move? Translating? Position Altering?

I'd love to help, this seems like a fun challenge for me, but I need more information about the end product for which you're looking.

Noah.

1 Reply

· Add your reply
  • Sort: 
avatar image

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 this cone is attached to the camera as a child). Then place a script on the cone and use "Void OnTriggerEnter(Collider other)" to do your movements. The only problem is with this is how are you going to decide if you're pushing 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 touching is whatever you can move. Only problem is clipping through walls and moving things like that...

Comment
whydoidoit

People who like this

1 Show 0 · 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

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

Error when using getComponent to use a variable 1 Answer

C# how to have a part of an object rotate while animation is being played 2 Answers

C# scriping help 0 Answers

Distribute terrain in zones 3 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