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
0
Question by Moonlight · Jun 29, 2010 at 07:37 AM · cameraplatformermoving-platformmove-with-moving-platform

Problem with moving platform and gun placment

Hi, I am currently using a script for a moving platform to keep my player on it.

(My player is from the Dastardly Bannana)

the script is

function OnTriggerEnter (other : Collider) { other.transform.parent = gameObject.transform; }

function OnTriggerExit(other : Collider) { other.transform.parent = null; }

While this dose work to keep my player on a platform, All my weapons that are attached to my weapons cam will be displaced are become separated at each mesh.

All I need is a fast and easy fix to this problem. Thank you.

(PS. Please don't just tell me to use the search function because I have and I have been looking for this for about two weeks now.)

(PSS. My platform moves both up, down, and side to side)

Thank you for your help.

Comment
Add comment · Show 4
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 StephanK · Jun 29, 2010 at 08:05 AM 0
Share

Are your weapons a child of your player?

avatar image Moonlight · Jun 29, 2010 at 08:07 AM 0
Share

I have $$anonymous$$y player then a cam then all of the weapons are children of that cam

you might look at the Dastardly Bannana fps prefab that they have so that you can see basicly what I am dealing with:)

avatar image Moonlight · Jun 29, 2010 at 08:09 AM 0
Share

I forgot a comma in my last comment in there

avatar image twinnightmare · Jun 29, 2010 at 10:44 PM 0
Share

Can you post your movement code for your platform?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by fherbst · Jun 29, 2010 at 08:17 AM

Parent your weapons to your player (you probably did this already). And you should tell your "OnTriggerEnter" and "Exit" functions to not affect the weapons - if these have colliders for themselves they will get attached to the platform, too. The easiest way to do this would maybe be to assign them to a different layer (e.g. Layer 8 = "PlayerWeapons")

Something like:

function OnTriggerEnter (other : Collider)
{
  if(other.gameObject.layer != 8)
  other.transform.parent = gameObject.transform;
}
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 Moonlight · Jun 29, 2010 at 07:52 PM 0
Share

This dose seem to help a little, but my weapons are still not staying where they should be. Got any more ideas? (please say yes, please say yes, please say yes)

avatar image Moonlight · Jun 29, 2010 at 07:55 PM 0
Share

agian, you might want to look at the Dastardly bannana project to see what I have, as I have not made many changes yet.

avatar image fherbst · Jun 30, 2010 at 08:59 AM 0
Share

Why does it seem to help "a little"? What happens?

avatar image Jason_DB · Jul 08, 2010 at 05:11 PM 0
Share

The player collider goes significantly lower than the weapons (which shouldn't have colliders anyway), so I don't think that the weapons would hit the platform.

avatar image
0

Answer by twinnightmare · Jun 29, 2010 at 10:57 PM

Give the player gameobject a tag of "player"

var playerObject : GameObject;

 function OnTriggerEnter (other : Collider) { 
 if(other.gameObject.tag == "player")
 {
   playerObject = other.gameObject;
 }

}

function OnTriggerExit(other : Collider) { if(other.gameObject.tag == "player") { playerObject = null; } }

then in your update for your plateform's position check on weather playerObject is null if not then update its position also.

if(playerObject != null)
{
   //update player position
}

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 Moonlight · Jun 29, 2010 at 11:21 PM 0
Share

this won't work because I use animation for my platform, not a script

avatar image twinnightmare · Jul 01, 2010 at 04:06 AM 0
Share

Well it was a shoot in the dark.

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

What is the easiest way to push a character controller with a moving platform? 0 Answers

Problem with moving (animated) platforms. need script to keep player object on 1 Answer

Moving Platform 1 Answer

moving platform jumping and then continuing it's path 0 Answers

Platforms again.. Working but.. 0 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