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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by IKilledKenny_2 · Mar 16, 2015 at 04:11 PM · javascriptcollisioncollidercharactercontrollerforce

OnCollisionEnter Push Object Problem

Hello Unity3D.i have a problem with my OnCollisionEnter Script.The problem is that i can't seem to push my opponent when in contact of an animation.For example.I have a character that does a certain animation that is suppose to send the opponent flying backwards.But when i do the animation to the opponent it plays but the opponent doesn't go anywhere.How can i make it that when my character plays the animation the opponent moves?If anyone knows how i can do this?Can you please tell me how?Because i suck when it comes to pushing object/characters.....

Heres the script.

 var player : GameObject;
 var enemy  : Transform;
 var myTransform : Transform;
 var Slash       : GameObject;
 var spawn       : Transform;
 
 
 
  
 function Awake() {
         myTransform = transform;
 }
 function Start() {
  
         enemy = GameObject.FindWithTag("Dummy").transform;
 }
   
     
 
 function OnCollisionEnter(collision : Collision){
  
  if(collision.gameObject.tag == "Dummy"){
  
   if(player.animation.IsPlaying("Sweep_Kick"))
 collision.transform.gameObject.animation.Play ("Stand_Air_Hit_back");
 Instantiate(Slash,spawn.transform.position,spawn.transform.rotation);
 }
 if(player.animation.IsPlaying("Violets_Bicycle_Kick")){
 enemy.transform.gameObject.animation.Play("Violets_Bicycle_Kick_Hit_Part_One");{
     }
 }
 if(player.animation.IsPlaying("Violets_Bicycle_Kick_Part_2")){
 enemy.transform.gameObject.animation.Play("Violets_Bicycle_Kick_Hit_Part_Two");{
     }
 }
 if(player.animation.IsPlaying("Lance_Kick_2")){
 if (collision.rigidbody)
 enemy.transform.gameObject.animation.Play("Air_Hit_Going_Up");{
 collision.rigidbody.AddForce (Vector3.up * 50000, ForceMode.Impulse);
 
     }
 }
 if(player.animation.IsPlaying("Falcon_Punch")){
 enemy.transform.gameObject.animation.Play("Hit_Flying");
 
 
  
      
          
     }
  }
Comment
Add comment · Show 8
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 hexagonius · Mar 16, 2015 at 05:24 PM 0
Share

Is OnCollisionEnter even triggered?

Is one of the if statements successfully entered?

Which of them is not working, there's animation plays and AddForces?

avatar image TRG96 · Mar 16, 2015 at 06:01 PM 0
Share

function OnCollisionEnter(collision : Collision){

if(collision.gameObject.tag == "Dummy"){ Debug.Log("Colliding") }

check if the collisions are being triggered

avatar image IKilledKenny_2 · Mar 16, 2015 at 07:50 PM 0
Share

Wait they all work its just lines 35-40 that doesn't work.Like when i do the lance kick animation the opponent does it but he does get the force added to him.

avatar image IKilledKenny_2 · Mar 16, 2015 at 07:53 PM 0
Share

The animations play.But the enemy doesn't take force.How can i make it that when my character plays the animation lance kick 2 the opponent that got kick with it goes flying backwards?Like the force is not being added to the enemy

avatar image hexagonius · Mar 16, 2015 at 09:46 PM 0
Share

Either the rigidbody is kinematic, or your animation is affecting the transforms position.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

Collider question 0 Answers

What's wrong with my code? (Collision, JS) 2 Answers

Collision Detection in Capsule Collider 0 Answers

Respawn when a character hits an object with a tag of "Kill" , but after 3 deaths the controller is destroyed 0 Answers

Character controller falling down 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