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 /
avatar image
0
Question by smasgames · Jun 01, 2011 at 09:09 PM · gameobjectplayercarchange

script help gameobject to playercar

i need the gameobject to be PlayerCar (which is the only object it should collide with)

public var explosionPrefab : Transform;

function OnCollisionEnter(collidedObject : Collision) {
if (collidedObject.gameObject.tag == "Finish") {
Destroy(collidedObject.gameObject);
}
}

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 iggy · Jun 01, 2011 at 09:31 PM 0
Share

what exactly are you asking us?

avatar image smasgames · Jun 01, 2011 at 09:40 PM 0
Share

im making a car game were the players car collides with the other cars and destroys then instantly. so i need someone to change the script so it the other cars ONLY get destroyed when collided with the players cqr

avatar image Anxo · Jun 01, 2011 at 10:14 PM 0
Share

make sure the player's car is not tagged "Finish". If thats not the answer, please try to ask the question in a way that we know what your problem is.

What you are trying to do:

What is actually happening:

What you think is causing the problem:

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by punkorange · Jun 01, 2011 at 10:11 PM

When attached to an object, this script function should check collisions to see if they are "OtherPlayer"s or not, if so it will remove them.

public var explosionPrefab : Transform;

function OnCollisionEnter(col: Collision){ if (col.gameObject.tag == "OtherPlayer") { Destroy(col.GameObject); }

Comment
Add comment · Show 2 · 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 smasgames · Jun 02, 2011 at 04:46 PM 0
Share

thanks i have 2 enemy cars and 1 player car. i apply it to the enemy car called "Computercar". i then changed the tag from "OtherPlayer" to "Player". i then aply the explosion.prefab. now i play it and it doesnt work then i hit the car but it works if the enemy car 1 hits enemy car 2. what went wrong?

avatar image smasgames · Jun 02, 2011 at 04:50 PM 0
Share

i added the script to the player car and it worked thanks punkorange.

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

Player moves faster when fps is higher? 1 Answer

Changing or replace objects 2 Answers

Change AI Follow Players 1 Answer

How do I change what player I want to controll when there is multiple players? 2 Answers

Modifying several gameobjects with an editor 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