kandi background
Explore Kits

Guns | Guns基于SpringBoot 2,致力于做更简洁的后台管理系统,完美整合springmvc shiro mybatisplus beetl!Guns项目代码简洁,注释丰富,上手容易,同时Guns包含许多基础模块,可以直接作为一个后台管理系统的脚手架! | Object-Relational Mapping library

 by   stylefeng Java Version: Current License: LGPL-3.0

 by   stylefeng Java Version: Current License: LGPL-3.0

Download this library from

kandi X-RAY | Guns Summary

Guns is a Java library typically used in Utilities, Object-Relational Mapping, Spring Boot, Spring, JPA applications. Guns has no bugs, it has no vulnerabilities, it has build file available, it has a Weak Copyleft License and it has medium support. You can download it from GitHub.
1.用户管理 2.角色管理 3.部门管理 4.菜单管理 5.字典管理 6.业务日志 7.登录日志 8.监控管理 9.通知管理 10.职务管理 11.代码生成 12.在线参数配置.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Guns has a medium active ecosystem.
  • It has 3233 star(s) with 1504 fork(s). There are 208 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 45 open issues and 22 have been closed. On average issues are closed in 74 days. There are 25 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Guns is current.
Guns Support
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Guns Support
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

quality kandi Quality

  • Guns has 0 bugs and 0 code smells.
Guns Quality
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Guns Quality
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

securitySecurity

  • Guns has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Guns code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
Guns Security
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Guns Security
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

license License

  • Guns is licensed under the LGPL-3.0 License. This license is Weak Copyleft.
  • Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.
Guns License
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Guns License
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping

buildReuse

  • Guns releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • Guns saves you 14606 person hours of effort in developing the same functionality from scratch.
  • It has 21667 lines of code, 46 functions and 396 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
Guns Reuse
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Guns Reuse
Best in #Object-Relational Mapping
Average in #Object-Relational Mapping
Top functions reviewed by kandi - BETA

kandi has reviewed Guns and discovered the below as its top functions. This is intended to give you an instant insight into Guns implemented functionality, and help decide if they suit your requirements.

  • Filter the request .
  • helper method to convert a pojo object to a string
  • Login user
  • Read file .
  • Handle a method signature point .
  • Gets user menu nodes .
  • get the IP address of the client
  • get avatar for current user
  • List of positions for a user
  • select menu tree

Guns Key Features

Guns基于SpringBoot 2,致力于做更简洁的后台管理系统,完美整合springmvc + shiro + mybatis-plus + beetl!Guns项目代码简洁,注释丰富,上手容易,同时Guns包含许多基础模块(用户管理,角色管理,部门管理,字典管理等10个模块),可以直接作为一个后台管理系统的脚手架!

beetl对前台页面的拆分与包装

copy iconCopydownload iconDownload
<!--左侧导航开始-->
    @include("/common/_tab.html"){}
<!--左侧导航结束-->

<!--右侧部分开始-->
    @include("/common/_right.html"){}
<!--右侧部分结束-->

<!--右侧边栏开始-->
    @include("/common/_theme.html"){}
<!--右侧边栏结束-->

极简的图片上传方法

copy iconCopydownload iconDownload
var avatarUp = new $WebUpload("avatar");
avatarUp.init();

swagger api管理使用说明

copy iconCopydownload iconDownload
 @ApiOperation("业务测试接口")
 @ApiImplicitParams({
         @ApiImplicitParam(name = "moduleName", value = "模块名称", required = true, dataType = "String"),
         @ApiImplicitParam(name = "bizChName", value = "业务名称", required = true, dataType = "String"),
         @ApiImplicitParam(name = "bizEnName", value = "业务英文名称", required = true, dataType = "String"),
         @ApiImplicitParam(name = "path", value = "项目生成类路径", required = true, dataType = "String")
 })
 @RequestMapping(value = "/generate", method = RequestMethod.POST)

How can I rename my creature's model's hierarchy without breaking animations?

copy iconCopydownload iconDownload
private static void RenameObject(GameObject gameObject, Animator animator, string newName)
{
    if (!gameObject)
    {
        throw new ArgumentException("No object provided", nameof(gameObject));
    }

    if (string.IsNullOrWhiteSpace(newName))
    {
        throw new ArgumentException("Object name may not be empty!", nameof(newName));
    }

    if (!animator)
    {
        throw new ArgumentException($"Selected object {gameObject} is not a child of an {nameof(Animator)}!", nameof(gameObject));
    }

    if (gameObject.transform == animator.transform)
    {
        return;
    }

    // get the relative path from the animator root to this object's parent
    var path = AnimationUtility.CalculateTransformPath(gameObject.transform.parent, animator.transform);

    if (gameObject.transform.parent != animator.transform)
    {
        path += "/";
    }

    // then append the old and new names
    var oldPath = path + gameObject.name;
    var newPath = path + newName;

    // get the runtime Animation controller
    var controller = animator.runtimeAnimatorController;

    // get all clips used by this controller
    var clips = controller.animationClips;

    var changeableObjects = new List<Object>(clips.Length + 1) { gameObject };
    changeableObjects.AddRange(clips);

    Undo.RecordObjects(changeableObjects.ToArray(), "Change animated object name");

    // Go through all clips
    foreach (var clip in clips)
    {
        var floatBindingInfo = new List<AnimationFloatBindingInfo>();

        // Get and store all FLOAT keyframe bindings
        foreach (var binding in AnimationUtility.GetCurveBindings(clip))
        {
            var curve = AnimationUtility.GetEditorCurve(clip, binding);
            var curveInfo = new AnimationFloatBindingInfo(binding, curve);

            ReplaceBindingPath(curveInfo, oldPath, newPath);

            floatBindingInfo.Add(curveInfo);
        }

        var objectBindingInfos = new List<AnimationObjectBindingInfo>();

        // also do the same for all reference keyframe bindings 
        foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
        {
            var curve = AnimationUtility.GetObjectReferenceCurve(clip, binding);
            var curveInfo = new AnimationObjectBindingInfo(binding, curve);

            ReplaceBindingPath(curveInfo, oldPath, newPath);

            objectBindingInfos.Add(curveInfo);
        }

        // a little check to avoid unnecessary work -> are there any affected property curves at all?
        if (floatBindingInfo.Count + objectBindingInfos.Count > 0)
        {
            // Now erase all curves 
            clip.ClearCurves();

            // and assign back the stored ones
            AnimationUtility.SetEditorCurves(clip, floatBindingInfo.Select(info => info.Binding).ToArray(), floatBindingInfo.Select(info => info.Curve).ToArray());
            AnimationUtility.SetObjectReferenceCurves(clip, objectBindingInfos.Select(info => info.Binding).ToArray(), objectBindingInfos.Select(info => info.Curve).ToArray());

            EditorUtility.SetDirty(clip);
        }
    }

    // finally rename the object
    gameObject.name = newName;

    EditorUtility.SetDirty(gameObject);
}
-----------------------
CATRigHub001Bone004
 └ CATRigHub001Bone004Bone001
    └ Rig  <-------- Collider
public class Rename : MonoBehaviour
{
    public string boneName;
    [NonSerialized] public string partName;

    void Awake()
    {
        partName = name;
        name = boneName;
    }
}
-----------------------
CATRigHub001Bone004
 └ CATRigHub001Bone004Bone001
    └ Rig  <-------- Collider
public class Rename : MonoBehaviour
{
    public string boneName;
    [NonSerialized] public string partName;

    void Awake()
    {
        partName = name;
        name = boneName;
    }
}

SpawnObject for ak(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server

copy iconCopydownload iconDownload
[Server]
public void spawnTime()
{
    StartCoroutine(spawn());
}

[Server]
public IEnumerator spawn()
{
    Debug.Log("oldu");
    yield return new WaitForSeconds(1);
    int a = Random.Range(0, guns.Length);
    GameObject gun =Instantiate(guns[a], 
    spawnPoint.position,Quaternion.identity);
    gun.transform.SetParent(transform);
    NetworkServer.Spawn(gun);


    uint gunNetId = gun.GetComponent<NetworkIdentity>().netId;
    uint parentNetId = transform.root.GetComponent<NetworkIdentity>().netId;
    RpcSetParent(parentNetId, gunNetId);
}

[ClientRpc]
void RpcSetParent(uint parentNetId, uint childNetId)
{
    Transform child = NetworkClient.spawned[childNetId].transform;
    Transform parent = NetworkClient.spawned[parentNetId].transform;

    child.SetParent(parent);
}
Start(){
    NetworkIdentity nid = transform.root.GetComponent<NetworkIdentity>();

    if(nid.isServer)
    {
        spawnTime();
    }
}
-----------------------
[Server]
public void spawnTime()
{
    StartCoroutine(spawn());
}

[Server]
public IEnumerator spawn()
{
    Debug.Log("oldu");
    yield return new WaitForSeconds(1);
    int a = Random.Range(0, guns.Length);
    GameObject gun =Instantiate(guns[a], 
    spawnPoint.position,Quaternion.identity);
    gun.transform.SetParent(transform);
    NetworkServer.Spawn(gun);


    uint gunNetId = gun.GetComponent<NetworkIdentity>().netId;
    uint parentNetId = transform.root.GetComponent<NetworkIdentity>().netId;
    RpcSetParent(parentNetId, gunNetId);
}

[ClientRpc]
void RpcSetParent(uint parentNetId, uint childNetId)
{
    Transform child = NetworkClient.spawned[childNetId].transform;
    Transform parent = NetworkClient.spawned[parentNetId].transform;

    child.SetParent(parent);
}
Start(){
    NetworkIdentity nid = transform.root.GetComponent<NetworkIdentity>();

    if(nid.isServer)
    {
        spawnTime();
    }
}

Gremlin Neptune query similar users based on common ratings count

copy iconCopydownload iconDownload
  g.addV("user").property("name", "alice").as("u1").
  addV("user").property("name", "jen").as("u2").
  addV("user").property("name", "dave").as("u3").
  addV("movie").property("name", "the wild bunch").as("m1").
  addV("movie").property("name", "young guns").as("m2").
  addV("movie").property("name", "unforgiven").as("m3").
  addE("friend").from("u1").to("u2").
  addE("friend").from("u1").to("u3").
  addE("friend").from("u2").to("u3").
  addE("friend").from("u2").to("u1").
  addE("like").from("u2").to("m1").
  addE("like").from("u2").to("m2").
  addE("like").from("u3").to("m2").
  addE("like").from("u3").to("m3").
  addE("like").from("u1").to("m1").
  addE("like").from("u1").to("m2")  
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count())    


==>[dave:1,alice:2]    
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>       by(values,desc)  

==>[alice:2,dave:1]     
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc)    

==>[[id:61353,label:user,name:[dave]]:1,[id:61349,label:user,name:[alice]]:2] 
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc).
......9>   select(keys)  

==>[[id:61353,label:user,name:[dave]],[id:61349,label:user,name:[alice]]]  
-----------------------
  g.addV("user").property("name", "alice").as("u1").
  addV("user").property("name", "jen").as("u2").
  addV("user").property("name", "dave").as("u3").
  addV("movie").property("name", "the wild bunch").as("m1").
  addV("movie").property("name", "young guns").as("m2").
  addV("movie").property("name", "unforgiven").as("m3").
  addE("friend").from("u1").to("u2").
  addE("friend").from("u1").to("u3").
  addE("friend").from("u2").to("u3").
  addE("friend").from("u2").to("u1").
  addE("like").from("u2").to("m1").
  addE("like").from("u2").to("m2").
  addE("like").from("u3").to("m2").
  addE("like").from("u3").to("m3").
  addE("like").from("u1").to("m1").
  addE("like").from("u1").to("m2")  
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count())    


==>[dave:1,alice:2]    
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>       by(values,desc)  

==>[alice:2,dave:1]     
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc)    

==>[[id:61353,label:user,name:[dave]]:1,[id:61349,label:user,name:[alice]]:2] 
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc).
......9>   select(keys)  

==>[[id:61353,label:user,name:[dave]],[id:61349,label:user,name:[alice]]]  
-----------------------
  g.addV("user").property("name", "alice").as("u1").
  addV("user").property("name", "jen").as("u2").
  addV("user").property("name", "dave").as("u3").
  addV("movie").property("name", "the wild bunch").as("m1").
  addV("movie").property("name", "young guns").as("m2").
  addV("movie").property("name", "unforgiven").as("m3").
  addE("friend").from("u1").to("u2").
  addE("friend").from("u1").to("u3").
  addE("friend").from("u2").to("u3").
  addE("friend").from("u2").to("u1").
  addE("like").from("u2").to("m1").
  addE("like").from("u2").to("m2").
  addE("like").from("u3").to("m2").
  addE("like").from("u3").to("m3").
  addE("like").from("u1").to("m1").
  addE("like").from("u1").to("m2")  
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count())    


==>[dave:1,alice:2]    
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>       by(values,desc)  

==>[alice:2,dave:1]     
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc)    

==>[[id:61353,label:user,name:[dave]]:1,[id:61349,label:user,name:[alice]]:2] 
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc).
......9>   select(keys)  

==>[[id:61353,label:user,name:[dave]],[id:61349,label:user,name:[alice]]]  
-----------------------
  g.addV("user").property("name", "alice").as("u1").
  addV("user").property("name", "jen").as("u2").
  addV("user").property("name", "dave").as("u3").
  addV("movie").property("name", "the wild bunch").as("m1").
  addV("movie").property("name", "young guns").as("m2").
  addV("movie").property("name", "unforgiven").as("m3").
  addE("friend").from("u1").to("u2").
  addE("friend").from("u1").to("u3").
  addE("friend").from("u2").to("u3").
  addE("friend").from("u2").to("u1").
  addE("like").from("u2").to("m1").
  addE("like").from("u2").to("m2").
  addE("like").from("u3").to("m2").
  addE("like").from("u3").to("m3").
  addE("like").from("u1").to("m1").
  addE("like").from("u1").to("m2")  
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count())    


==>[dave:1,alice:2]    
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>       by(values,desc)  

==>[alice:2,dave:1]     
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc)    

==>[[id:61353,label:user,name:[dave]]:1,[id:61349,label:user,name:[alice]]:2] 
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc).
......9>   select(keys)  

==>[[id:61353,label:user,name:[dave]],[id:61349,label:user,name:[alice]]]  
-----------------------
  g.addV("user").property("name", "alice").as("u1").
  addV("user").property("name", "jen").as("u2").
  addV("user").property("name", "dave").as("u3").
  addV("movie").property("name", "the wild bunch").as("m1").
  addV("movie").property("name", "young guns").as("m2").
  addV("movie").property("name", "unforgiven").as("m3").
  addE("friend").from("u1").to("u2").
  addE("friend").from("u1").to("u3").
  addE("friend").from("u2").to("u3").
  addE("friend").from("u2").to("u1").
  addE("like").from("u2").to("m1").
  addE("like").from("u2").to("m2").
  addE("like").from("u3").to("m2").
  addE("like").from("u3").to("m3").
  addE("like").from("u1").to("m1").
  addE("like").from("u1").to("m2")  
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count())    


==>[dave:1,alice:2]    
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by("name").
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>       by(values,desc)  

==>[alice:2,dave:1]     
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc)    

==>[[id:61353,label:user,name:[dave]]:1,[id:61349,label:user,name:[alice]]:2] 
gremlin> g.V().
......1>   has('name','jen').as('jen').
......2>   sideEffect(out('like').store('movies')).
......3>   out('friend').
......4>   group().
......5>     by(valueMap(true)).
......6>     by(out('like').where(within('movies')).count()).
......7>     order(local).
......8>     by(values,asc).
......9>   select(keys)  

==>[[id:61353,label:user,name:[dave]],[id:61349,label:user,name:[alice]]]  

Fandom-py: Unable to get image by using page.images[0]

copy iconCopydownload iconDownload
sk_fandom = MediaWiki(url='https://soul-knight.fandom.com/api.php')

How to increase the size of categories that found in type of items

copy iconCopydownload iconDownload
const findCategory = findThis => ({
    [findThis || 'Search Item']: PopularItems.reduce(
    (acc, itm) => itm.type.includes(findThis) ? acc + 1 : acc, 0
  ) || 'Not found in category-array'
});
const category = ["Action", "Female Games", "Boys Games", "Kids", "Team", "Guns", "Parkour", "Logic", "Adventure", "Hero Games", "Fun Games", "War Games", "Space Games", "Free To Play", "F2P", "Gache Game", "NFT Game", "Zombie Games", "Multiplayer", "Open-world Game", "Mobile Games", "PvP Game", "Clan Games"];

const PopularItems = [{
    imgPath: "",
    name: "Genshin Impact",
    type: ["Free To Play", "F2P", "Gache Game", "Adventure", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "213131",
    rate: "2.1"
  },
  {
    imgPath: "",
    name: "Crossfire",
    type: ["Free To Play", "F2P", "Action", "Guns", "Multiplayer", "Boys Games", "War Games", "Open-world Game", "Fun Games"],
    views: "12161",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Spiderman",
    type: ["Parkour", "Action", "Adventure", "Hero Games", "Fun Games"],
    views: "232411",
    rate: "3.9"
  },
  {
    imgPath: "",
    name: "Apocalypse",
    type: ["Zombie Games", "Multiplayer", "Open-world Game", "Action", "Guns", "Team", "Fun Games"],
    views: "232411",
    rate: "4.0"
  },
  {
    imgPath: "",
    name: "Honkai Impact",
    type: ["Adventure", "Free To Play", "F2P", "Gache Game", "Action", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "MIR4",
    type: ["NFT Game", "Action", "Hero Games", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "232411",
    rate: "4.5"
  },
  {
    imgPath: "",
    name: "Minecraft",
    type: ["Kids", "Multiplayer", "Open-world Game", "Fun Games", "Adventure"],
    views: "232411",
    rate: "4.6"
  },
  {
    imgPath: "",
    name: "Clash of Clan",
    type: ["Mobile Games", "PvP Game", "Open-world Game", "Fun Games", "War Games", "Hero Games", "Adventure"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Call of Duty",
    type: ["War Games", "Multiplayer", "Open-world Game", "Team", "Guns", "Adventure", "Free To Play", "F2P", "Gache Game"],
    views: "232411",
    rate: "4.2"
  },
  {
    imgPath: "",
    name: "Valorant",
    type: ["Multiplayer", "Open-world Game", "Team", "Guns", "Parkour", "Action"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Mobile Legends Bang Bang",
    type: ["Multiplayer", "Open-world Game", "Mobile Games", "PvP Game", "Clan Games", "Hero Games"],
    views: "232411",
    rate: "4.3"
  }
];

const findCategory = findThis => ({
  [findThis || 'Search Item']: PopularItems.reduce(
    (acc, itm) => itm.type.includes(findThis) ? acc + 1 : acc, 0
  ) || 'Not found in category-array'
});

console.log('search: null\n', findCategory());
console.log('search: War Games\n', findCategory('War Games'));
console.log('search: Multiplayer\n', findCategory('Multiplayer'));
-----------------------
const findCategory = findThis => ({
    [findThis || 'Search Item']: PopularItems.reduce(
    (acc, itm) => itm.type.includes(findThis) ? acc + 1 : acc, 0
  ) || 'Not found in category-array'
});
const category = ["Action", "Female Games", "Boys Games", "Kids", "Team", "Guns", "Parkour", "Logic", "Adventure", "Hero Games", "Fun Games", "War Games", "Space Games", "Free To Play", "F2P", "Gache Game", "NFT Game", "Zombie Games", "Multiplayer", "Open-world Game", "Mobile Games", "PvP Game", "Clan Games"];

const PopularItems = [{
    imgPath: "",
    name: "Genshin Impact",
    type: ["Free To Play", "F2P", "Gache Game", "Adventure", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "213131",
    rate: "2.1"
  },
  {
    imgPath: "",
    name: "Crossfire",
    type: ["Free To Play", "F2P", "Action", "Guns", "Multiplayer", "Boys Games", "War Games", "Open-world Game", "Fun Games"],
    views: "12161",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Spiderman",
    type: ["Parkour", "Action", "Adventure", "Hero Games", "Fun Games"],
    views: "232411",
    rate: "3.9"
  },
  {
    imgPath: "",
    name: "Apocalypse",
    type: ["Zombie Games", "Multiplayer", "Open-world Game", "Action", "Guns", "Team", "Fun Games"],
    views: "232411",
    rate: "4.0"
  },
  {
    imgPath: "",
    name: "Honkai Impact",
    type: ["Adventure", "Free To Play", "F2P", "Gache Game", "Action", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "MIR4",
    type: ["NFT Game", "Action", "Hero Games", "Multiplayer", "Open-world Game", "Fun Games"],
    views: "232411",
    rate: "4.5"
  },
  {
    imgPath: "",
    name: "Minecraft",
    type: ["Kids", "Multiplayer", "Open-world Game", "Fun Games", "Adventure"],
    views: "232411",
    rate: "4.6"
  },
  {
    imgPath: "",
    name: "Clash of Clan",
    type: ["Mobile Games", "PvP Game", "Open-world Game", "Fun Games", "War Games", "Hero Games", "Adventure"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Call of Duty",
    type: ["War Games", "Multiplayer", "Open-world Game", "Team", "Guns", "Adventure", "Free To Play", "F2P", "Gache Game"],
    views: "232411",
    rate: "4.2"
  },
  {
    imgPath: "",
    name: "Valorant",
    type: ["Multiplayer", "Open-world Game", "Team", "Guns", "Parkour", "Action"],
    views: "232411",
    rate: "4.1"
  },
  {
    imgPath: "",
    name: "Mobile Legends Bang Bang",
    type: ["Multiplayer", "Open-world Game", "Mobile Games", "PvP Game", "Clan Games", "Hero Games"],
    views: "232411",
    rate: "4.3"
  }
];

const findCategory = findThis => ({
  [findThis || 'Search Item']: PopularItems.reduce(
    (acc, itm) => itm.type.includes(findThis) ? acc + 1 : acc, 0
  ) || 'Not found in category-array'
});

console.log('search: null\n', findCategory());
console.log('search: War Games\n', findCategory('War Games'));
console.log('search: Multiplayer\n', findCategory('Multiplayer'));

iOS Swift - How to do 360 degree flip animation using CABasicAnimation and CATransform3DRotate with &quot;m34&quot; transform?

copy iconCopydownload iconDownload
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
rotate.duration = 2
cardView.layer.add(rotate, forKey: nil)
-----------------------
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
rotate.duration = 2
cardView.layer.add(rotate, forKey: nil)
-----------------------
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
rotate.duration = 2
cardView.layer.add(rotate, forKey: nil)
-----------------------
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
var perspective = CATransform3DIdentity
perspective.m34 = 1 / -200
cardView.layer.transform = perspective
let rotate = CABasicAnimation(keyPath: "transform.rotation.y")
rotate.fromValue = 0
rotate.byValue = CGFloat.pi * 2
rotate.duration = 2
cardView.layer.add(rotate, forKey: nil)

Clustering in R using K-mean

copy iconCopydownload iconDownload
library(fastDummies)

df_dummy <- dummy_columns(df, select_columns = "Yeast", remove_selected_columns = TRUE)

res <- NbClust(df_dummy[2:9], min.nc = 2, max.nc = 15, method = "ward.D2")

How to join to column after imputation

copy iconCopydownload iconDownload
library(tidyverse)
library(mice)

imi <- mice(data, m=5, maxit=10)
imi_complete <- complete(imi)

res <- data %>%
  dplyr::left_join(.,  imi_complete %>% dplyr::select(Name, ABV, EBC), by = "Name") %>%
  dplyr::select(-c(ABV.x, EBC.x)) %>%
  dplyr::rename("ABV" = ABV.y, "EBC" = EBC.y)
 head(res)
                                 Name  IBU     OG  PH AttenuationLevel FermentationTempCelsius                       Yeast ABV EBC
1                                Buzz 60.0 1044.0 4.4             75.0                      19  Wyeast 1056 - American Ale 4.5  20
2                       Trashy Blonde 41.5 1041.7 4.4             76.0                      18  Wyeast 1056 - American Ale 4.1  15
3 Berliner Weisse With Yuzu - B-Sides  8.0 1040.0 3.2             83.0                      21  Wyeast 1056 - American Ale 4.2   8
4                        Pilsen Lager 55.0 1060.0 4.4             80.0                       9  Wyeast 2007 - Pilsen Lager 6.3  30
5                  Avery Brown Dredge 59.0 1069.0 4.4             67.0                      10  Wyeast 2007 - Pilsen Lager 7.2  10
6                      Electric India 38.0 1045.0 4.4             88.9                      22 Wyeast 3711 - French Saison 7.5  15
library(tidyverse)

df_orig %>% 
  dplyr::mutate(ABV = df_new$ABV, EBC = df_new$EBC) 
  id ABV EBC    third
1  1 -61 -58 37.94029
2  2 -80 -67 47.81479
3  3 -62 -66 48.85903
4  4 -69 -78 23.18026
5  5 -51 -77 29.91952
df_orig <-
  structure(
    list(
      id = c(1, 2, 3, 4, 5),
      ABV = c(
        38.9932923251763,
        20.0923723727465,
        37.640398349613,
        31.4673039061017,
        49.192731983494
      ),
      EBC = c(
        42.341671793256,
        32.936319950968,
        33.8184517389163,
        21.5938150603324,
        22.8182014194317
      ),
      third = c(
        37.9402944352478,
        47.8147878032178,
        48.8590325415134,
        23.1802612892352,
        29.9195193173364
      )
    ),
    class = "data.frame",
    row.names = c(NA,-5L)
  )

df_new <-
  structure(
    list(
      ABV = c(-61,-80,-62,-69,-51),
      EBC = c(-58,-67,-66,-78,-77)
    ),
    class = c("rowwise_df", "tbl_df", "tbl",
              "data.frame"),
    row.names = c(NA,-5L),
    groups = structure(
      list(.rows = structure(
        list(1L, 2L, 3L, 4L, 5L),
        ptype = integer(0),
        class = c("vctrs_list_of",
                  "vctrs_vctr", "list")
      )),
      row.names = c(NA,-5L),
      class = c("tbl_df",
                "tbl", "data.frame")
    )
  )
-----------------------
library(tidyverse)
library(mice)

imi <- mice(data, m=5, maxit=10)
imi_complete <- complete(imi)

res <- data %>%
  dplyr::left_join(.,  imi_complete %>% dplyr::select(Name, ABV, EBC), by = "Name") %>%
  dplyr::select(-c(ABV.x, EBC.x)) %>%
  dplyr::rename("ABV" = ABV.y, "EBC" = EBC.y)
 head(res)
                                 Name  IBU     OG  PH AttenuationLevel FermentationTempCelsius                       Yeast ABV EBC
1                                Buzz 60.0 1044.0 4.4             75.0                      19  Wyeast 1056 - American Ale 4.5  20
2                       Trashy Blonde 41.5 1041.7 4.4             76.0                      18  Wyeast 1056 - American Ale 4.1  15
3 Berliner Weisse With Yuzu - B-Sides  8.0 1040.0 3.2             83.0                      21  Wyeast 1056 - American Ale 4.2   8
4                        Pilsen Lager 55.0 1060.0 4.4             80.0                       9  Wyeast 2007 - Pilsen Lager 6.3  30
5                  Avery Brown Dredge 59.0 1069.0 4.4             67.0                      10  Wyeast 2007 - Pilsen Lager 7.2  10
6                      Electric India 38.0 1045.0 4.4             88.9                      22 Wyeast 3711 - French Saison 7.5  15
library(tidyverse)

df_orig %>% 
  dplyr::mutate(ABV = df_new$ABV, EBC = df_new$EBC) 
  id ABV EBC    third
1  1 -61 -58 37.94029
2  2 -80 -67 47.81479
3  3 -62 -66 48.85903
4  4 -69 -78 23.18026
5  5 -51 -77 29.91952
df_orig <-
  structure(
    list(
      id = c(1, 2, 3, 4, 5),
      ABV = c(
        38.9932923251763,
        20.0923723727465,
        37.640398349613,
        31.4673039061017,
        49.192731983494
      ),
      EBC = c(
        42.341671793256,
        32.936319950968,
        33.8184517389163,
        21.5938150603324,
        22.8182014194317
      ),
      third = c(
        37.9402944352478,
        47.8147878032178,
        48.8590325415134,
        23.1802612892352,
        29.9195193173364
      )
    ),
    class = "data.frame",
    row.names = c(NA,-5L)
  )

df_new <-
  structure(
    list(
      ABV = c(-61,-80,-62,-69,-51),
      EBC = c(-58,-67,-66,-78,-77)
    ),
    class = c("rowwise_df", "tbl_df", "tbl",
              "data.frame"),
    row.names = c(NA,-5L),
    groups = structure(
      list(.rows = structure(
        list(1L, 2L, 3L, 4L, 5L),
        ptype = integer(0),
        class = c("vctrs_list_of",
                  "vctrs_vctr", "list")
      )),
      row.names = c(NA,-5L),
      class = c("tbl_df",
                "tbl", "data.frame")
    )
  )
-----------------------
library(tidyverse)
library(mice)

imi <- mice(data, m=5, maxit=10)
imi_complete <- complete(imi)

res <- data %>%
  dplyr::left_join(.,  imi_complete %>% dplyr::select(Name, ABV, EBC), by = "Name") %>%
  dplyr::select(-c(ABV.x, EBC.x)) %>%
  dplyr::rename("ABV" = ABV.y, "EBC" = EBC.y)
 head(res)
                                 Name  IBU     OG  PH AttenuationLevel FermentationTempCelsius                       Yeast ABV EBC
1                                Buzz 60.0 1044.0 4.4             75.0                      19  Wyeast 1056 - American Ale 4.5  20
2                       Trashy Blonde 41.5 1041.7 4.4             76.0                      18  Wyeast 1056 - American Ale 4.1  15
3 Berliner Weisse With Yuzu - B-Sides  8.0 1040.0 3.2             83.0                      21  Wyeast 1056 - American Ale 4.2   8
4                        Pilsen Lager 55.0 1060.0 4.4             80.0                       9  Wyeast 2007 - Pilsen Lager 6.3  30
5                  Avery Brown Dredge 59.0 1069.0 4.4             67.0                      10  Wyeast 2007 - Pilsen Lager 7.2  10
6                      Electric India 38.0 1045.0 4.4             88.9                      22 Wyeast 3711 - French Saison 7.5  15
library(tidyverse)

df_orig %>% 
  dplyr::mutate(ABV = df_new$ABV, EBC = df_new$EBC) 
  id ABV EBC    third
1  1 -61 -58 37.94029
2  2 -80 -67 47.81479
3  3 -62 -66 48.85903
4  4 -69 -78 23.18026
5  5 -51 -77 29.91952
df_orig <-
  structure(
    list(
      id = c(1, 2, 3, 4, 5),
      ABV = c(
        38.9932923251763,
        20.0923723727465,
        37.640398349613,
        31.4673039061017,
        49.192731983494
      ),
      EBC = c(
        42.341671793256,
        32.936319950968,
        33.8184517389163,
        21.5938150603324,
        22.8182014194317
      ),
      third = c(
        37.9402944352478,
        47.8147878032178,
        48.8590325415134,
        23.1802612892352,
        29.9195193173364
      )
    ),
    class = "data.frame",
    row.names = c(NA,-5L)
  )

df_new <-
  structure(
    list(
      ABV = c(-61,-80,-62,-69,-51),
      EBC = c(-58,-67,-66,-78,-77)
    ),
    class = c("rowwise_df", "tbl_df", "tbl",
              "data.frame"),
    row.names = c(NA,-5L),
    groups = structure(
      list(.rows = structure(
        list(1L, 2L, 3L, 4L, 5L),
        ptype = integer(0),
        class = c("vctrs_list_of",
                  "vctrs_vctr", "list")
      )),
      row.names = c(NA,-5L),
      class = c("tbl_df",
                "tbl", "data.frame")
    )
  )
-----------------------
library(tidyverse)
library(mice)

imi <- mice(data, m=5, maxit=10)
imi_complete <- complete(imi)

res <- data %>%
  dplyr::left_join(.,  imi_complete %>% dplyr::select(Name, ABV, EBC), by = "Name") %>%
  dplyr::select(-c(ABV.x, EBC.x)) %>%
  dplyr::rename("ABV" = ABV.y, "EBC" = EBC.y)
 head(res)
                                 Name  IBU     OG  PH AttenuationLevel FermentationTempCelsius                       Yeast ABV EBC
1                                Buzz 60.0 1044.0 4.4             75.0                      19  Wyeast 1056 - American Ale 4.5  20
2                       Trashy Blonde 41.5 1041.7 4.4             76.0                      18  Wyeast 1056 - American Ale 4.1  15
3 Berliner Weisse With Yuzu - B-Sides  8.0 1040.0 3.2             83.0                      21  Wyeast 1056 - American Ale 4.2   8
4                        Pilsen Lager 55.0 1060.0 4.4             80.0                       9  Wyeast 2007 - Pilsen Lager 6.3  30
5                  Avery Brown Dredge 59.0 1069.0 4.4             67.0                      10  Wyeast 2007 - Pilsen Lager 7.2  10
6                      Electric India 38.0 1045.0 4.4             88.9                      22 Wyeast 3711 - French Saison 7.5  15
library(tidyverse)

df_orig %>% 
  dplyr::mutate(ABV = df_new$ABV, EBC = df_new$EBC) 
  id ABV EBC    third
1  1 -61 -58 37.94029
2  2 -80 -67 47.81479
3  3 -62 -66 48.85903
4  4 -69 -78 23.18026
5  5 -51 -77 29.91952
df_orig <-
  structure(
    list(
      id = c(1, 2, 3, 4, 5),
      ABV = c(
        38.9932923251763,
        20.0923723727465,
        37.640398349613,
        31.4673039061017,
        49.192731983494
      ),
      EBC = c(
        42.341671793256,
        32.936319950968,
        33.8184517389163,
        21.5938150603324,
        22.8182014194317
      ),
      third = c(
        37.9402944352478,
        47.8147878032178,
        48.8590325415134,
        23.1802612892352,
        29.9195193173364
      )
    ),
    class = "data.frame",
    row.names = c(NA,-5L)
  )

df_new <-
  structure(
    list(
      ABV = c(-61,-80,-62,-69,-51),
      EBC = c(-58,-67,-66,-78,-77)
    ),
    class = c("rowwise_df", "tbl_df", "tbl",
              "data.frame"),
    row.names = c(NA,-5L),
    groups = structure(
      list(.rows = structure(
        list(1L, 2L, 3L, 4L, 5L),
        ptype = integer(0),
        class = c("vctrs_list_of",
                  "vctrs_vctr", "list")
      )),
      row.names = c(NA,-5L),
      class = c("tbl_df",
                "tbl", "data.frame")
    )
  )
-----------------------
library(tidyverse)
library(mice)

imi <- mice(data, m=5, maxit=10)
imi_complete <- complete(imi)

res <- data %>%
  dplyr::left_join(.,  imi_complete %>% dplyr::select(Name, ABV, EBC), by = "Name") %>%
  dplyr::select(-c(ABV.x, EBC.x)) %>%
  dplyr::rename("ABV" = ABV.y, "EBC" = EBC.y)
 head(res)
                                 Name  IBU     OG  PH AttenuationLevel FermentationTempCelsius                       Yeast ABV EBC
1                                Buzz 60.0 1044.0 4.4             75.0                      19  Wyeast 1056 - American Ale 4.5  20
2                       Trashy Blonde 41.5 1041.7 4.4             76.0                      18  Wyeast 1056 - American Ale 4.1  15
3 Berliner Weisse With Yuzu - B-Sides  8.0 1040.0 3.2             83.0                      21  Wyeast 1056 - American Ale 4.2   8
4                        Pilsen Lager 55.0 1060.0 4.4             80.0                       9  Wyeast 2007 - Pilsen Lager 6.3  30
5                  Avery Brown Dredge 59.0 1069.0 4.4             67.0                      10  Wyeast 2007 - Pilsen Lager 7.2  10
6                      Electric India 38.0 1045.0 4.4             88.9                      22 Wyeast 3711 - French Saison 7.5  15
library(tidyverse)

df_orig %>% 
  dplyr::mutate(ABV = df_new$ABV, EBC = df_new$EBC) 
  id ABV EBC    third
1  1 -61 -58 37.94029
2  2 -80 -67 47.81479
3  3 -62 -66 48.85903
4  4 -69 -78 23.18026
5  5 -51 -77 29.91952
df_orig <-
  structure(
    list(
      id = c(1, 2, 3, 4, 5),
      ABV = c(
        38.9932923251763,
        20.0923723727465,
        37.640398349613,
        31.4673039061017,
        49.192731983494
      ),
      EBC = c(
        42.341671793256,
        32.936319950968,
        33.8184517389163,
        21.5938150603324,
        22.8182014194317
      ),
      third = c(
        37.9402944352478,
        47.8147878032178,
        48.8590325415134,
        23.1802612892352,
        29.9195193173364
      )
    ),
    class = "data.frame",
    row.names = c(NA,-5L)
  )

df_new <-
  structure(
    list(
      ABV = c(-61,-80,-62,-69,-51),
      EBC = c(-58,-67,-66,-78,-77)
    ),
    class = c("rowwise_df", "tbl_df", "tbl",
              "data.frame"),
    row.names = c(NA,-5L),
    groups = structure(
      list(.rows = structure(
        list(1L, 2L, 3L, 4L, 5L),
        ptype = integer(0),
        class = c("vctrs_list_of",
                  "vctrs_vctr", "list")
      )),
      row.names = c(NA,-5L),
      class = c("tbl_df",
                "tbl", "data.frame")
    )
  )

mongodb change field type to int32

copy iconCopydownload iconDownload
db.collection.aggregate([
  {
    "$addFields": {
      "season": {
        "$convert": {
          "input": "$season",
          "to": "int",
          //"onError": "expression",
          //"onNull": "expression"
          }
        },
        "episode_no": {
          "$convert": {
            "input": "$episode_no",
            "to": "int",
            //"onError": "expression",
            //"onNull": "expression"
            }
          }
        }
      },
      {
        "$merge": {
          "into": "collection",
          "on": "_id",
          "whenMatched": "replace"
        }
      }
    ])

Array.forEach Updating each Item in Array on click

copy iconCopydownload iconDownload
let cannon = {
    color : "rgb(0, 0, 255)",
    radius : 30,
    speed : .5,
    rounds : 1,

    velocity : {
        x: 1,
        y: 1
    }
}
this.velocity = {...config.velocity};
projectilesArray.splice(pIndex, 1);
-----------------------
let cannon = {
    color : "rgb(0, 0, 255)",
    radius : 30,
    speed : .5,
    rounds : 1,

    velocity : {
        x: 1,
        y: 1
    }
}
this.velocity = {...config.velocity};
projectilesArray.splice(pIndex, 1);
-----------------------
let cannon = {
    color : "rgb(0, 0, 255)",
    radius : 30,
    speed : .5,
    rounds : 1,

    velocity : {
        x: 1,
        y: 1
    }
}
this.velocity = {...config.velocity};
projectilesArray.splice(pIndex, 1);

Community Discussions

Trending Discussions on Guns
  • How can I rename my creature's model's hierarchy without breaking animations?
  • SpawnObject for ak(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server
  • Gremlin Neptune query similar users based on common ratings count
  • Fandom-py: Unable to get image by using page.images[0]
  • How to increase the size of categories that found in type of items
  • iOS Swift - How to do 360 degree flip animation using CABasicAnimation and CATransform3DRotate with &quot;m34&quot; transform?
  • How to make python program that runs game files at the same time as main code
  • Clustering in R using K-mean
  • Rotate self between an arc on the local axis Godot
  • How to join to column after imputation
Trending Discussions on Guns

QUESTION

How can I rename my creature's model's hierarchy without breaking animations?

Asked 2022-Mar-31 at 08:48

I am a beginner at Unity in terms of skill so please explain as if you were talking to a child if you can!

PROBLEM

I would like to change these names here:

enter image description here

I would like to rename them for two reasons:

  1. so they are more intelligible

  2. because I am using many different assets from the store and each has a different hierarchy with different names and I want to standardize the names so that I can use the below code to determine which part of the creature's body was shot so that it works for every creature

 public    void            CreatureHit(string bodyPart, GunInfo usedWeapon, float intensity)                    // for guns
 {

     usedWeapon.PlayHit(creatureSounds);
     if (creatureInfo.healthPoints > 0)                                                                        // to prevent dead creatures from being shot
     {
         if ("Torso" == bodyPart || "LeftUpperArm" == bodyPart                                                // if the part that was hit was the arms or torso
                 || "RightUpperArm" == bodyPart || "LeftLowerArm" == bodyPart                                // if the part that was hit was the arms or torso
                 || "RightLowerArm" == bodyPart)
         {
             creatureInfo.healthPoints -= usedWeapon.damage * intensity;                                     // deal standard dmg

             if (creatureInfo.healthPoints <= 0)
                 creatureInfo.deathType = CreatureInfo.BODYSHOT;
         }
         else if ("Head" == bodyPart)                                                                        // if the part that was hit was the head
         {
             creatureInfo.healthPoints -= usedWeapon.damage * 10 * intensity;                                // deal 10x dmg
             audioSource.PlayOneShot(creatureSounds.hitHead, 1);


             if (creatureInfo.healthPoints <= 0)
                 creatureInfo.deathType = CreatureInfo.HEADSHOT;
         }
         else if ("RightUpperLeg" == bodyPart || "LeftUpperLeg" == bodyPart
             || "RightLowerLeg" == bodyPart || "LeftLowerLeg" == bodyPart)
         {
             creatureInfo.healthPoints -= usedWeapon.damage / 2 * intensity;                                    // deal half dmg
             if (creatureInfo.healthPoints <= 0)
                 creatureInfo.deathType = CreatureInfo.BODYSHOT;
         }
     }
 }   

WHAT I TRIED

I renamed them in the hierarchy but then the animations stopped working. I found an old thread from the Unity forum asking if this was possible in 2015 and the OP was told that it wasn't. There were some later technical replies and I felt overwhelmed so I thought I should just create my own thread.

NOTE: there are multiple dozens of characters each with 10+ animations so ideally I need a very efficient solution.

ANSWER

Answered 2022-Mar-31 at 08:48

In general you still can't unfortunately. (At least not that simple see below).

The AnimationClips are based on strings storing the relative path from the Animator to the according GameObject the type of the according component and finally the name of the animated serialized fields and properties.

If any of those change e.g. because you renamed the object or change the hierarchy in general the connection is lost and the animation breaks.

You could implement an editor script method that

  • goes through the affected Animator (GetComponentInParent) of the object
  • iterates through all used AnimationClips
  • iterates through each clips property bindings
  • redirects the property path accordingly to your renaming

This could look somewhat like this

private static void RenameObject(GameObject gameObject, Animator animator, string newName)
{
    if (!gameObject)
    {
        throw new ArgumentException("No object provided", nameof(gameObject));
    }

    if (string.IsNullOrWhiteSpace(newName))
    {
        throw new ArgumentException("Object name may not be empty!", nameof(newName));
    }

    if (!animator)
    {
        throw new ArgumentException($"Selected object {gameObject} is not a child of an {nameof(Animator)}!", nameof(gameObject));
    }

    if (gameObject.transform == animator.transform)
    {
        return;
    }

    // get the relative path from the animator root to this object's parent
    var path = AnimationUtility.CalculateTransformPath(gameObject.transform.parent, animator.transform);

    if (gameObject.transform.parent != animator.transform)
    {
        path += "/";
    }

    // then append the old and new names
    var oldPath = path + gameObject.name;
    var newPath = path + newName;

    // get the runtime Animation controller
    var controller = animator.runtimeAnimatorController;

    // get all clips used by this controller
    var clips = controller.animationClips;

    var changeableObjects = new List<Object>(clips.Length + 1) { gameObject };
    changeableObjects.AddRange(clips);

    Undo.RecordObjects(changeableObjects.ToArray(), "Change animated object name");

    // Go through all clips
    foreach (var clip in clips)
    {
        var floatBindingInfo = new List<AnimationFloatBindingInfo>();

        // Get and store all FLOAT keyframe bindings
        foreach (var binding in AnimationUtility.GetCurveBindings(clip))
        {
            var curve = AnimationUtility.GetEditorCurve(clip, binding);
            var curveInfo = new AnimationFloatBindingInfo(binding, curve);

            ReplaceBindingPath(curveInfo, oldPath, newPath);

            floatBindingInfo.Add(curveInfo);
        }

        var objectBindingInfos = new List<AnimationObjectBindingInfo>();

        // also do the same for all reference keyframe bindings 
        foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
        {
            var curve = AnimationUtility.GetObjectReferenceCurve(clip, binding);
            var curveInfo = new AnimationObjectBindingInfo(binding, curve);

            ReplaceBindingPath(curveInfo, oldPath, newPath);

            objectBindingInfos.Add(curveInfo);
        }

        // a little check to avoid unnecessary work -> are there any affected property curves at all?
        if (floatBindingInfo.Count + objectBindingInfos.Count > 0)
        {
            // Now erase all curves 
            clip.ClearCurves();

            // and assign back the stored ones
            AnimationUtility.SetEditorCurves(clip, floatBindingInfo.Select(info => info.Binding).ToArray(), floatBindingInfo.Select(info => info.Curve).ToArray());
            AnimationUtility.SetObjectReferenceCurves(clip, objectBindingInfos.Select(info => info.Binding).ToArray(), objectBindingInfos.Select(info => info.Curve).ToArray());

            EditorUtility.SetDirty(clip);
        }
    }

    // finally rename the object
    gameObject.name = newName;

    EditorUtility.SetDirty(gameObject);
}

Since this use case is quite common I took some time to implement an EditorWindow for this. It is still a bit raw but works and supports also undo redo ;) You can find it here

-> Select the object in the Hierarchy -> right click -> "Rename safe for Animator"

You could of course add some shortcut to it etc. that's up to you ;)

Here a little demo of the dialog in action, renaming some nested objects and also performing some undo/redo

enter image description here


However, an alternative in your use case to simply get your code to work with the names as they are might be using tags instead.

As I see it your code is based on three different cases so you could simply have a tag for each like e.g. Head, Arms, Legs and assign and check those accordingly (GameObject.CompareTag) and not touch the names and animations at all.

Source https://stackoverflow.com/questions/71686007

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install Guns

You can download it from GitHub.
You can use Guns like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Guns component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Consider Popular Object-Relational Mapping Libraries
Compare Object-Relational Mapping Libraries with Highest Support
Compare Object-Relational Mapping Libraries with Highest Quality
Compare Object-Relational Mapping Libraries with Highest Security
Compare Object-Relational Mapping Libraries with Permissive License
Compare Object-Relational Mapping Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.