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 ryanaalley05 · Dec 27, 2019 at 11:31 AM · fightingame

i made a code and the sword doesn't show up...

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class FightMode : MonoBehaviour { public Transform Sword; public Transform player; public int WhichPlayer; //Player 1's sword rotation variables //Up public int Player1UpRotationX; public int Player1UpRotationY; public int Player1UpRotationZ; //Left public int Player1LeftRotationX; public int Player1LeftRotationY; public int Player1LeftRotationZ; //Down public int Player1DownRotationX; public int Player1DownRotationY; public int Player1DownRotationZ; //Right public int Player1RightRotationX; public int Player1RightRotationY; public int Player1RightRotationZ; //Player 2's sword rotaion variables //Up public int Player2UpRotationX; public int Player2UpRotationY; public int Player2UpRotationZ; //Left public int Player2LeftRotationX; public int Player2LeftRotationY; public int Player2LeftRotationZ; //Down public int Player2DownRotationX; public int Player2DownRotationY; public int Player2DownRotationZ; //Right public int Player2RightRotationX; public int Player2RightRotationY; public int Player2RightRotationZ; // Start is called before the first frame update public void AttackMode() { Coop2.AttackMode = 1; }

 // Update is called once per frame
 public void Update()
 {
     if (WhichPlayer == 0) // First player's controll over attacking
     {
         if (Coop2.AttackMode == 1)
         {
             if (Input.GetKey(KeyCode.Space))
             {
                 //Up
                 if (Input.GetKey(KeyCode.W))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player1UpRotationX, Player1UpRotationY, Player1UpRotationZ, Sword.rotation.w);
                 }
                 //Left
                 if (Input.GetKey(KeyCode.A))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player1LeftRotationX, Player1LeftRotationY, Player1LeftRotationZ, Sword.rotation.w);
                 }
                 //Down
                 if (Input.GetKey(KeyCode.S))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player1DownRotationX, Player1DownRotationY, Player1DownRotationZ, Sword.rotation.w);
                 }
                 //Right
                 if (Input.GetKey(KeyCode.D))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player1RightRotationX, Player1RightRotationY, Player1RightRotationZ, Sword.rotation.w);
                 }
             }
         }
     }


     if (WhichPlayer == 1)// Second player's controll over attacking
     {
         if (Coop2.AttackMode == 1)
         {
             if (Input.GetKey(KeyCode.RightShift))
             {
                 //Up
                 if (Input.GetKey(KeyCode.UpArrow))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player2UpRotationX, Player2UpRotationY, Player2UpRotationZ, Sword.rotation.w);
                 }
                 //Left
                 if (Input.GetKey(KeyCode.LeftArrow))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player2LeftRotationX, Player2LeftRotationY, Player2LeftRotationZ, Sword.rotation.w);
                 }
                 //Down
                 if (Input.GetKey(KeyCode.DownArrow))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player2DownRotationX, Player2DownRotationY, Player2DownRotationZ, Sword.rotation.w);
                 }
                 //Right
                 if (Input.GetKey(KeyCode.RightArrow))
                 {
                     Sword.position = new Vector3(player.position.x, player.position.y, player.position.z);
                     Sword.rotation = new Quaternion(Player2RightRotationX, Player2RightRotationY, Player2RightRotationZ, Sword.rotation.w);
                 }
             }
         }
     }
 }

}

Comment
Add comment · Show 1
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 ryanaalley05 · Dec 24, 2019 at 02:42 AM 0
Share

the values of the rotations are as follows: Player1/2UpRotation = X:360 Y:0 Z:0 Player1/2downRotation = X:180 Y:0 Z:0 Player1/2LeftRotation = X:90 Y:0 Z:0 Player1/2RightRotation = X:-90 Y:0 Z:0

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by dtbrown0801 · Dec 28, 2019 at 01:26 AM

Does it show up in the hierarchy? If it does than I would check if it has an animation (maybe an accident) that changes the position Or if it is a first person the camera settings.

Also maybe the sword's mesh acts like a plain and can not be seen in those values of rotation.

Comment
Add comment · 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
0

Answer by ryanaalley05 · Jan 09, 2020 at 07:00 AM

Never mind. I already scrapped the idea for a better one thank you!

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

117 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 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 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 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 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

Detect if player is left or right of enemy 1 Answer

[2D Fighting Game] Prevent characters from colliding or standing on top of each other when one jumps right on top of the other? 0 Answers

for fighting what is the script required for movement of the player.? 0 Answers

How to make an AI and Player code for a fighting game similar to tekken or street fighter? 0 Answers

When I want to kill an enemy with a strong attack, the enemy just gets stuck. How do I fix this? 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