Jump to content
Unity Insider Forum

Banenchen

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Banenchen's Achievements

Member

Member (2/3)

0

Reputation

  1. Ich möchte type-Effectnis machen aber da steht,dass nicht alle zahlen ausgeben using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenuAttribute(fileName = "Pokemon", menuName = "Pokemon/Create new pokemon")] public class PokemonBase : ScriptableObject { [SerializeField] string name; [TextArea] [SerializeField] string description; [SerializeField] Sprite frontSprite; [SerializeField] Sprite backSprite; [SerializeField] PokemonType type1; [SerializeField] PokemonType type2; //basestats [SerializeField] int maxHp; [SerializeField] int attack; [SerializeField] int defens; [SerializeField] int spDefense; [SerializeField] int spAttack; [SerializeField] int speed; [SerializeField] List<LearnableMove> learnableMoves; public string Name { get { return name;} } public string Description { get { return description;} } public Sprite FrontSprite { get { return frontSprite;} } public Sprite BackSprite { get { return backSprite;} } public PokemonType Type1 { get { return type1;} } public PokemonType Type2 { get { return type2;} } public int MaxHp { get { return maxHp;} } public int Attack { get { return attack;} } public int Defens { get { return defens;} } public int SpDefense { get { return spDefense;} } public int SpAttack { get { return spAttack;} } public int Speed { get { return speed;} } public List<LearnableMove> LearnableMoves { get{return learnableMoves;} } } [System.Serializable] public class LearnableMove { [SerializeField] MoveBase moveBase; [SerializeField] int level; public MoveBase Base { get{ return moveBase;} } public int Level { get{ return level;} } } public enum PokemonType { None, Normal, Feuer, Wasser, Elektro, Pflanze, Gift, Flug, Eis, Boden, Kampf, Psycho, Käfer, Stein, Geist, Drache, Fee } public class TypeChart { public PokemonType attackType; public PokemonType defenseType; float[][] chart = {new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 0.5f, 0f, 1f, 1f, 0.5f }, new float[] { 1f, 0.5f, 0.5f, 1f, 2f, 2f, 1f, 1f, 1f, 1f, 1f, 2f, 0.5f, 1f, 0.5f, 1f, 2f }, new float[] { 1f, 2f, 0.5f, 2f, 0.5f, 1f, 1f, 1f, 2f, 1f, 1f, 1f, 2f, 1f, 0.5f, 1f, 1f }, new float[] { 1f, 1f, 2f, 0.5f,0.5f, 2f, 1f, 1f, 0f, 2f, 1f, 1f, 1f, 1f, 0.5f, 1f, 1f }, new float[] { 1f, 0.5f, 2f, 2f, 0.5f, 1f, 1f, 0.5f, 2f, 0.5f, 1f, 0.5f, 2f, 1f, 0.5f, 1f, 0.5f }, new float[] { 1f, 0.5f, 0.5f, 1f, 2f, 0.5f, 1f, 1f, 2f, 2f, 1f, 1f, 1f, 1f, 2f, 1f, 0.5f }, }; public float GetEffectiveness() { if(attackType == PokemonType.None || defenseType == PokemonType.None) { return 1; int row = (int)attackType -1; int col = (int)defenseType -1; return chart[row][col]; } } }
  2. Es funktioniert zwar, dass er die Spikes spawnt aber diese fallen dann nicht runter. Woran liegt das? using System.Collections; using System.Collections.Generic; using UnityEngine; public class spikes : MonoBehaviour { public Enemy myLife; public bool deaktiv; public void Update() { if(myLife.currentHealth ==155) { myLife.Spikes.transform.position = new Vector3(42.68138f, -0.681396f, 0f); deaktiv = true; } } void Start() { deaktiv = false; } } Script eins using System.Collections; using System.Collections.Generic; using UnityEngine; public class Boss : MonoBehaviour { public Enemy myLife; public spikes spSpikes; public void Update() { if(myLife.aktiv = false) { spSpikes.Update(); } if(spSpikes.deaktiv = false) { myLife.lost(); } } } Script 2
  3. ich hab den fehler gefunden aber ich weiss nicht wie man ihn verbessert. es wird nur eine cammera erkannt aber wie mache ich das jeder spieler eine cammera hat
  4. using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; [RequireComponent(typeof(CharacterController))] public class SC_FPSController : MonoBehaviour { public float walkingSpeed = 7.5f; public float runningSpeed = 11.5f; public float jumpSpeed = 8.0f; public float gravity = 20.0f; public Camera playerCamera; public float lookSpeed = 2.0f; public float lookXLimit = 45.0f; PhotonView view; CharacterController characterController; Vector3 moveDirection = Vector3.zero; float rotationX = 0; [HideInInspector] public bool canMove = true; void Start() { view = GetComponent<PhotonView>(); characterController = GetComponent<CharacterController>(); // Lock cursor Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void Update() { if (view.IsMine) { // We are grounded, so recalculate move direction based on axes Vector3 forward = transform.TransformDirection(Vector3.forward); Vector3 right = transform.TransformDirection(Vector3.right); // Press Left Shift to run bool isRunning = Input.GetKey(KeyCode.LeftShift); float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0; float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0; float movementDirectionY = moveDirection.y; moveDirection = (forward * curSpeedX) + (right * curSpeedY); if (Input.GetButton("Jump") && canMove && characterController.isGrounded) { moveDirection.y = jumpSpeed; } else { moveDirection.y = movementDirectionY; } // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied // as an acceleration (ms^-2) if (!characterController.isGrounded) { moveDirection.y -= gravity * Time.deltaTime; } // Move the controller characterController.Move(moveDirection * Time.deltaTime); // Player and Camera rotation if (canMove) { rotationX += -Input.GetAxis("Mouse Y") * lookSpeed; rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit); playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0); transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0); } } } } was ist der fehler das if can move nicht geht
  5. Das ist der fehlercode Assets\Script\SpawnPlayers.cs(20,61): error CS1061: 'Vector3' does not contain a definition for 'Range' and no accessible extension method 'Range' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?) Es ist ein multiplayer script das die spieler gespawnt werden using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class SpawnPlayers : MonoBehaviour { public GameObject playerPrefab; public float minX; public float minY; public float minZ; public float maxX; public float maxY; public float maxZ; private void Start() { Vector3 randomPosition = new Vector3(randomPosition.Range(minX, minY, minZ), randomPosition.Range(maxX, maxY, maxZ)); PhotonNetwork.Instantiate(playerPrefab.name, randomPosition, Quaternion.identity); } }
  6. Hallo Ich find leider kein script für ein leben und schaden und tutorials finde ich nicht. kann mir bitte jemand ein script geben oder ein tutorial geben
  7. möchte mein spiel veröffentlichen hab aber diese assets benutzt https://assetstore.unity.com/packages/2d/textures-materials/stone/yughues-free-stone-materials-12962 https://assetstore.unity.com/packages/2d/textures-materials/floors/vis-pbr-grass-textures-198071 https://assetstore.unity.com/packages/2d/textures-materials/nature/grass-and-flowers-pack-1-17100 https://assetstore.unity.com/packages/2d/textures-materials/4k-pbr-ground-textures-206354
  8. ich möchte dass ich nur einmal springen kann bis ich wieder auf dem boden bin ich kann mehrmals springen es ist zur helfte mein code ich hab den vor ein paar wochen bei einem tutorial gemacht(ich kenn leider den youtuber name nicht)
  9. Ich habe ein script bei dem sich mein characktär bewegt aber die groundet funktion funktioniert nicht bitte helft mir using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharackterController2D : MonoBehaviour { // Move player in 2D space public float maxSpeed = 3.4f; public float jumpHeight = 6.5f; public float gravityScale = 1.5f; public Camera mainCamera; bool facingRight = true; float moveDirection = 0; public bool isGrounded = false; Vector3 cameraPos; Rigidbody2D r2d; CapsuleCollider2D mainCollider; Transform t; // Use this for initialization void Start() { t = transform; r2d = GetComponent<Rigidbody2D>(); mainCollider = GetComponent<CapsuleCollider2D>(); r2d.freezeRotation = true; r2d.collisionDetectionMode = CollisionDetectionMode2D.Continuous; r2d.gravityScale = gravityScale; facingRight = t.localScale.x > 0; if (mainCamera) { cameraPos = mainCamera.transform.position; } } // Update is called once per frame void Update() { // Movement controls if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)) && (isGrounded || Mathf.Abs(r2d.velocity.x) > 0.01f)) { moveDirection = Input.GetKey(KeyCode.A) ? -1 : 1; } else { if (isGrounded || r2d.velocity.magnitude < 0.01f) { moveDirection = 0; } } // Change facing direction if (moveDirection != 0) { if (moveDirection < 0 && !facingRight) { facingRight = true; t.localScale = new Vector3(Mathf.Abs(t.localScale.x), t.localScale.y, transform.localScale.z); } if (moveDirection > 0 && facingRight) { facingRight = false; t.localScale = new Vector3(-Mathf.Abs(t.localScale.x), t.localScale.y, t.localScale.z); } } // Jumping if (Input.GetKeyDown(KeyCode.Space) && isGrounded) { r2d.velocity = new Vector2(r2d.velocity.x, jumpHeight); } // Camera follow if (mainCamera) { mainCamera.transform.position = new Vector3(t.position.x, cameraPos.y, cameraPos.z); } } void FixedUpdate() { Bounds colliderBounds = mainCollider.bounds; float colliderRadius = mainCollider.size.x * 0.4f * Mathf.Abs(transform.localScale.x); Vector3 groundCheckPos = colliderBounds.min + new Vector3(colliderBounds.size.x * 0.5f, colliderRadius * 0.9f, 0); // Check if player is grounded Collider2D[] colliders = Physics2D.OverlapCircleAll(groundCheckPos, colliderRadius); //Check if any of the overlapping colliders are not player collider, if so, set isGrounded to true isGrounded = false; if (colliders.Length > 0) { for (int i = 0; i < colliders.Length; i++) { if (colliders[i] != mainCollider) { isGrounded = true; break; } } } // Apply movement velocity r2d.velocity = new Vector2((moveDirection) * maxSpeed, r2d.velocity.y); // Simple debug Debug.DrawLine(groundCheckPos, groundCheckPos - new Vector3(0, colliderRadius, 0), isGrounded ? Color.green : Color.red); Debug.DrawLine(groundCheckPos, groundCheckPos - new Vector3(colliderRadius, 0, 0), isGrounded ? Color.green : Color.red); } }
  10. Hallo ich möchte ein spiel erstellen bei dem ich mit der leertaste mein object um 90 grad drehen kann. könnte mir bitte jemand den code dafür schreiben
  11. Hallo ich habe ein unity project erstellt in dem ich kostenlose Texturen des assets stores verwendet habe. Darf ich dieses spiel trotzdem kostenlos veröffentlichen? Bin neu in unity eine Andwort wäre hilfreich
×
×
  • Create New...