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
1
Question by Infinity · May 09, 2011 at 05:18 PM · vehicletank

Vehicle (tank) for my character

Hi,

I have a problem, I want my character control a tank for a little period of time on my game. So I need ideas for doing an script. First by a collider I want the player disappear and you control the tank (but I want to store in some way my character inside the tank, I want to stop using the tank by using jump button). So I don't know how to do it. It's important too to say that the character prefab, have some hiden parts, by default, so I don't know if this is a problem.

What I can do to solve my problem?

Lot of thanks

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

Answer by Antony-Blackett · May 09, 2011 at 09:38 PM

When the character collides with the tank, assign a GameObject variable on the tank to the player object. Then call SetActiveRecursive(false); on the player object. After that enable the tank controls.

To get the character out of the tank make the Jump button and control on the tank itself that when pressed calls SetActiveRecursive(true); on the player GameObject variable you set earlier and sets the player's position to the position you want them to be when the jump out of the tank begins.

Good luck.

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 Infinity · May 12, 2011 at 11:12 PM 0
Share

I have done a function with this:

function OnCollisionEnter(collision : Collision) { collision.gameObject.SetActiveRecursive(false); }

But my player doesn't look like if it is on the tank. What I'm doing wrong?

avatar image Antony-Blackett · May 13, 2011 at 02:23 AM 0
Share

Setting the player object active to false will make the player disapear. I though this is what you wanted as it'd look like the player went inside the tank, If you want the player on the tank then you'll have to disable collision for those two objects on impact and then set the player's parent collision.gameObject.transform.parent to a node on the tank that you wish your player to appear at. Then also set the player to is$$anonymous$$inematic = true on its rigidbody to stop it simulating. Then when the player exits the tank, do the opposite.

avatar image Infinity · May 13, 2011 at 09:16 AM 0
Share

But with the function I have done: OnCollisionEnter(collision : Collision) { collision.gameObject.SetActiveRecursive(false); } There is no effect X__X

avatar image Antony-Blackett · May 14, 2011 at 12:10 AM 0
Share

There will be, maybe you just can't see it. If the node that the physics body is on is not the root node of the player character then you'll have to find the root of the player character and deactivate that. Depending on how your scene is setup try this collision.gameObject.transform.root.gameObject.SetActiveRecursivley( false );

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

No one has followed this question yet.

Related Questions

Tank Turret move on XAxis by Mouse XAxis 1 Answer

Script for getting in and out of a tank 2 Answers

Controllable boat script 0 Answers

Enter Vehicle Script not working! 1 Answer

How to check hit on tank 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